From 29bac7280ddb97b1bbc4fedeb1336379219808ca Mon Sep 17 00:00:00 2001 From: Magliano Andrea Date: Tue, 22 Feb 2011 23:54:23 +0100 Subject: [PATCH] Bring in acpica 20110211, still not ok anyway (partially) sync with FreeBSD 8: * AcpiWalkNamespace post callbacks * wakable GPEs in acpi_probe_child() problems: * system reacts slowly * temp reads nonsense values --- sys/contrib/dev/acpica-unix/changes.txt | 1596 ++++++++++- sys/contrib/dev/acpica-unix/common/16bit.h | 165 -- sys/contrib/dev/acpica-unix/common/a16find.c | 962 ------- .../dev/acpica-unix/common/a16utils.asm | 915 ------- sys/contrib/dev/acpica-unix/common/adfile.c | 32 +- sys/contrib/dev/acpica-unix/common/adisasm.c | 268 +- sys/contrib/dev/acpica-unix/common/adwalk.c | 50 +- sys/contrib/dev/acpica-unix/common/dmextern.c | 743 +++++ sys/contrib/dev/acpica-unix/common/dmrestag.c | 15 +- sys/contrib/dev/acpica-unix/common/dmtable.c | 442 ++- sys/contrib/dev/acpica-unix/common/dmtbdump.c | 514 +++- sys/contrib/dev/acpica-unix/common/dmtbinfo.c | 1458 ++++++---- sys/contrib/dev/acpica-unix/common/getopt.c | 15 +- .../dev/acpica-unix/compiler/aslanalyze.c | 2186 ++------------- .../dev/acpica-unix/compiler/aslbtypes.c | 597 ++++ .../dev/acpica-unix/compiler/aslcodegen.c | 6 +- .../dev/acpica-unix/compiler/aslcompile.c | 159 +- .../dev/acpica-unix/compiler/aslcompiler.h | 286 +- .../dev/acpica-unix/compiler/aslcompiler.l | 12 +- .../dev/acpica-unix/compiler/aslcompiler.y | 20 +- .../dev/acpica-unix/compiler/asldefine.h | 24 +- .../dev/acpica-unix/compiler/aslerror.c | 95 +- .../dev/acpica-unix/compiler/aslfiles.c | 377 ++- .../dev/acpica-unix/compiler/aslfold.c | 2 +- .../dev/acpica-unix/compiler/aslglobal.h | 31 +- .../dev/acpica-unix/compiler/asllength.c | 2 +- .../dev/acpica-unix/compiler/asllisting.c | 253 +- .../dev/acpica-unix/compiler/aslload.c | 24 +- .../dev/acpica-unix/compiler/asllookup.c | 23 +- .../dev/acpica-unix/compiler/aslmain.c | 364 ++- sys/contrib/dev/acpica-unix/compiler/aslmap.c | 288 +- .../compiler/{asltypes.h => aslmessages.h} | 284 +- .../dev/acpica-unix/compiler/aslopcodes.c | 56 +- .../dev/acpica-unix/compiler/asloperands.c | 30 +- sys/contrib/dev/acpica-unix/compiler/aslopt.c | 4 +- .../dev/acpica-unix/compiler/aslpredef.c | 889 ++++++ .../dev/acpica-unix/compiler/aslresource.c | 356 ++- .../dev/acpica-unix/compiler/aslrestype1.c | 562 +--- .../{aslrestype1.c => aslrestype1i.c} | 591 +--- .../dev/acpica-unix/compiler/aslrestype2.c | 2400 +---------------- .../dev/acpica-unix/compiler/aslrestype2d.c | 814 ++++++ .../dev/acpica-unix/compiler/aslrestype2e.c | 645 +++++ .../dev/acpica-unix/compiler/aslrestype2q.c | 793 ++++++ .../dev/acpica-unix/compiler/aslrestype2w.c | 774 ++++++ .../dev/acpica-unix/compiler/aslstartup.c | 217 +- .../dev/acpica-unix/compiler/aslstubs.c | 20 +- .../dev/acpica-unix/compiler/asltransform.c | 65 +- .../dev/acpica-unix/compiler/asltree.c | 86 +- .../dev/acpica-unix/compiler/asltypes.h | 296 +- .../dev/acpica-unix/compiler/aslutils.c | 144 +- .../dbhistry.c => compiler/asluuid.c} | 212 +- .../compiler/{aslanalyze.c => aslwalks.c} | 2059 +++++++------- .../dev/acpica-unix/compiler/dtcompile.c | 658 +++++ .../dev/acpica-unix/compiler/dtcompiler.h | 526 ++++ .../dev/acpica-unix/compiler/dtexpress.c | 462 ++++ .../dev/acpica-unix/compiler/dtfield.c | 615 +++++ sys/contrib/dev/acpica-unix/compiler/dtio.c | 934 +++++++ .../psscope.c => compiler/dtsubtable.c} | 350 +-- .../dev/acpica-unix/compiler/dttable.c | 1544 +++++++++++ .../evevent.c => compiler/dttemplate.c} | 415 +-- .../dev/acpica-unix/compiler/dttemplate.h | 757 ++++++ .../dev/acpica-unix/compiler/dtutils.c | 937 +++++++ sys/contrib/dev/acpica-unix/debugger/dbcmds.c | 1492 +--------- .../dev/acpica-unix/debugger/dbdisply.c | 285 +- sys/contrib/dev/acpica-unix/debugger/dbexec.c | 54 +- .../dev/acpica-unix/debugger/dbfileio.c | 9 +- .../dev/acpica-unix/debugger/dbhistry.c | 4 +- .../dev/acpica-unix/debugger/dbinput.c | 232 +- .../dev/acpica-unix/debugger/dbmethod.c | 597 ++++ .../dev/acpica-unix/debugger/dbnames.c | 1006 +++++++ .../dev/acpica-unix/debugger/dbstats.c | 4 +- .../dev/acpica-unix/debugger/dbutils.c | 8 +- .../dev/acpica-unix/debugger/dbxface.c | 2 +- .../dev/acpica-unix/disassembler/dmbuffer.c | 2 +- .../dev/acpica-unix/disassembler/dmnames.c | 2 +- .../dev/acpica-unix/disassembler/dmobject.c | 8 +- .../dev/acpica-unix/disassembler/dmopcode.c | 14 +- .../dev/acpica-unix/disassembler/dmresrc.c | 4 +- .../dev/acpica-unix/disassembler/dmresrcl.c | 2 +- .../dev/acpica-unix/disassembler/dmresrcs.c | 2 +- .../dev/acpica-unix/disassembler/dmutils.c | 120 +- .../dev/acpica-unix/disassembler/dmwalk.c | 107 +- .../dev/acpica-unix/dispatcher/dsargs.c | 502 ++++ .../dev/acpica-unix/dispatcher/dscontrol.c | 496 ++++ .../dev/acpica-unix/dispatcher/dsfield.c | 32 +- .../dev/acpica-unix/dispatcher/dsinit.c | 20 +- .../dev/acpica-unix/dispatcher/dsmethod.c | 76 +- .../dev/acpica-unix/dispatcher/dsmthdat.c | 38 +- .../dev/acpica-unix/dispatcher/dsobject.c | 55 +- .../dev/acpica-unix/dispatcher/dsopcode.c | 754 +----- .../dev/acpica-unix/dispatcher/dsutils.c | 6 +- .../dev/acpica-unix/dispatcher/dswexec.c | 28 +- .../dev/acpica-unix/dispatcher/dswload.c | 719 +---- .../dispatcher/{dswload.c => dswload2.c} | 642 +---- .../dev/acpica-unix/dispatcher/dswscope.c | 2 +- .../dev/acpica-unix/dispatcher/dswstate.c | 12 +- sys/contrib/dev/acpica-unix/events/evevent.c | 64 +- sys/contrib/dev/acpica-unix/events/evgpe.c | 523 ++-- sys/contrib/dev/acpica-unix/events/evgpeblk.c | 893 +----- .../dev/acpica-unix/events/evgpeinit.c | 531 ++++ .../utmutex.c => events/evgpeutil.c} | 442 +-- sys/contrib/dev/acpica-unix/events/evmisc.c | 4 +- sys/contrib/dev/acpica-unix/events/evregion.c | 95 +- sys/contrib/dev/acpica-unix/events/evrgnini.c | 93 +- sys/contrib/dev/acpica-unix/events/evsci.c | 2 +- sys/contrib/dev/acpica-unix/events/evxface.c | 166 +- sys/contrib/dev/acpica-unix/events/evxfevnt.c | 664 +---- .../events/{evxfevnt.c => evxfgpe.c} | 760 +++--- sys/contrib/dev/acpica-unix/events/evxfregn.c | 48 +- .../dev/acpica-unix/executer/exconfig.c | 51 +- .../dev/acpica-unix/executer/exconvrt.c | 21 +- .../dev/acpica-unix/executer/excreate.c | 14 +- .../executer/{exstorob.c => exdebug.c} | 302 ++- sys/contrib/dev/acpica-unix/executer/exdump.c | 15 +- .../dev/acpica-unix/executer/exfield.c | 86 +- .../dev/acpica-unix/executer/exfldio.c | 165 +- sys/contrib/dev/acpica-unix/executer/exmisc.c | 24 +- .../dev/acpica-unix/executer/exmutex.c | 8 +- .../dev/acpica-unix/executer/exnames.c | 6 +- .../dev/acpica-unix/executer/exoparg1.c | 62 +- .../dev/acpica-unix/executer/exoparg2.c | 43 +- .../dev/acpica-unix/executer/exoparg3.c | 8 +- .../dev/acpica-unix/executer/exoparg6.c | 17 +- sys/contrib/dev/acpica-unix/executer/exprep.c | 109 +- .../dev/acpica-unix/executer/exregion.c | 91 +- .../dev/acpica-unix/executer/exresnte.c | 6 +- .../dev/acpica-unix/executer/exresolv.c | 10 +- .../dev/acpica-unix/executer/exresop.c | 10 +- .../dev/acpica-unix/executer/exstore.c | 225 +- .../dev/acpica-unix/executer/exstoren.c | 2 +- .../dev/acpica-unix/executer/exstorob.c | 16 +- .../dev/acpica-unix/executer/exsystem.c | 23 +- .../dev/acpica-unix/executer/exutils.c | 71 +- .../dev/acpica-unix/generate/lint/options.lnt | 6 +- sys/contrib/dev/acpica-unix/hardware/hwacpi.c | 2 +- sys/contrib/dev/acpica-unix/hardware/hwgpe.c | 147 +- sys/contrib/dev/acpica-unix/hardware/hwpci.c | 531 ++++ sys/contrib/dev/acpica-unix/hardware/hwregs.c | 233 +- .../dev/acpica-unix/hardware/hwsleep.c | 24 +- .../dev/acpica-unix/hardware/hwtimer.c | 6 +- .../dev/acpica-unix/hardware/hwvalid.c | 18 +- .../dev/acpica-unix/hardware/hwxface.c | 204 +- sys/contrib/dev/acpica-unix/include/acapps.h | 66 +- .../dev/acpica-unix/include/accommon.h | 2 +- .../dev/acpica-unix/include/acconfig.h | 20 +- sys/contrib/dev/acpica-unix/include/acdebug.h | 129 +- .../dev/acpica-unix/include/acdisasm.h | 185 +- .../dev/acpica-unix/include/acdispat.h | 52 +- .../dev/acpica-unix/include/acevents.h | 109 +- sys/contrib/dev/acpica-unix/include/acexcep.h | 6 +- .../dev/acpica-unix/include/acglobal.h | 99 +- sys/contrib/dev/acpica-unix/include/achware.h | 40 +- .../dev/acpica-unix/include/acinterp.h | 62 +- sys/contrib/dev/acpica-unix/include/aclocal.h | 127 +- .../dev/acpica-unix/include/acmacros.h | 22 +- sys/contrib/dev/acpica-unix/include/acnames.h | 2 +- .../dev/acpica-unix/include/acnamesp.h | 94 +- .../dev/acpica-unix/include/acobject.h | 34 +- .../dev/acpica-unix/include/acopcode.h | 2 +- .../dev/acpica-unix/include/acoutput.h | 27 +- .../dev/acpica-unix/include/acparser.h | 3 +- sys/contrib/dev/acpica-unix/include/acpi.h | 2 +- .../dev/acpica-unix/include/acpiosxf.h | 33 +- sys/contrib/dev/acpica-unix/include/acpixf.h | 156 +- .../dev/acpica-unix/include/acpredef.h | 97 +- sys/contrib/dev/acpica-unix/include/acresrc.h | 2 +- .../dev/acpica-unix/include/acrestyp.h | 4 +- .../dev/acpica-unix/include/acstruct.h | 34 +- .../dev/acpica-unix/include/actables.h | 10 +- sys/contrib/dev/acpica-unix/include/actbl.h | 124 +- sys/contrib/dev/acpica-unix/include/actbl1.h | 1010 ++----- sys/contrib/dev/acpica-unix/include/actbl2.h | 1086 +++++++- sys/contrib/dev/acpica-unix/include/actypes.h | 251 +- sys/contrib/dev/acpica-unix/include/acutils.h | 130 +- sys/contrib/dev/acpica-unix/include/amlcode.h | 11 +- .../dev/acpica-unix/include/amlresrc.h | 8 +- .../acpica-unix/include/platform/accygwin.h | 11 +- .../dev/acpica-unix/include/platform/acefi.h | 2 +- .../dev/acpica-unix/include/platform/acenv.h | 24 +- .../acpica-unix/include/platform/acfreebsd.h | 33 +- .../dev/acpica-unix/include/platform/acgcc.h | 4 +- .../acpica-unix/include/platform/acintel.h | 24 +- .../acpica-unix/include/platform/aclinux.h | 5 +- .../dev/acpica-unix/include/platform/acmsvc.h | 22 +- .../acpica-unix/include/platform/acnetbsd.h | 2 +- .../dev/acpica-unix/include/platform/acos2.h | 8 +- .../dev/acpica-unix/include/platform/acwin.h | 4 +- .../acpica-unix/include/platform/acwin64.h | 4 +- .../dev/acpica-unix/namespace/nsaccess.c | 16 +- .../dev/acpica-unix/namespace/nsalloc.c | 201 +- .../dev/acpica-unix/namespace/nsdump.c | 26 +- .../dev/acpica-unix/namespace/nsdumpdv.c | 4 +- .../dev/acpica-unix/namespace/nseval.c | 198 +- .../dev/acpica-unix/namespace/nsinit.c | 52 +- .../dev/acpica-unix/namespace/nsload.c | 5 +- .../dev/acpica-unix/namespace/nsnames.c | 10 +- .../dev/acpica-unix/namespace/nsobject.c | 2 +- .../dev/acpica-unix/namespace/nsparse.c | 4 +- .../dev/acpica-unix/namespace/nspredef.c | 768 +++--- .../dev/acpica-unix/namespace/nsrepair.c | 876 ++++++ .../dev/acpica-unix/namespace/nsrepair2.c | 883 ++++++ .../dev/acpica-unix/namespace/nssearch.c | 19 +- .../dev/acpica-unix/namespace/nsutils.c | 308 +-- .../dev/acpica-unix/namespace/nswalk.c | 215 +- .../dev/acpica-unix/namespace/nsxfeval.c | 106 +- .../dev/acpica-unix/namespace/nsxfname.c | 273 +- .../dev/acpica-unix/namespace/nsxfobj.c | 16 +- .../os_specific/service_layers/osunixdir.c | 35 +- .../os_specific/service_layers/osunixxf.c | 251 +- .../os_specific/service_layers/oswindir.c | 19 +- .../os_specific/service_layers/oswintbl.c | 44 +- .../os_specific/service_layers/oswinxf.c | 447 +-- sys/contrib/dev/acpica-unix/osunixxf.c | 251 +- sys/contrib/dev/acpica-unix/parser/psargs.c | 8 +- sys/contrib/dev/acpica-unix/parser/psloop.c | 154 +- sys/contrib/dev/acpica-unix/parser/psopcode.c | 2 +- sys/contrib/dev/acpica-unix/parser/psparse.c | 28 +- sys/contrib/dev/acpica-unix/parser/psscope.c | 2 +- sys/contrib/dev/acpica-unix/parser/pstree.c | 2 +- sys/contrib/dev/acpica-unix/parser/psutils.c | 6 +- sys/contrib/dev/acpica-unix/parser/pswalk.c | 2 +- sys/contrib/dev/acpica-unix/parser/psxface.c | 21 +- .../dev/acpica-unix/resources/rsaddr.c | 2 +- .../dev/acpica-unix/resources/rscalc.c | 2 +- .../dev/acpica-unix/resources/rscreate.c | 18 +- .../dev/acpica-unix/resources/rsdump.c | 2 +- .../dev/acpica-unix/resources/rsinfo.c | 2 +- sys/contrib/dev/acpica-unix/resources/rsio.c | 2 +- sys/contrib/dev/acpica-unix/resources/rsirq.c | 2 +- .../dev/acpica-unix/resources/rslist.c | 8 +- .../dev/acpica-unix/resources/rsmemory.c | 2 +- .../dev/acpica-unix/resources/rsmisc.c | 6 +- .../dev/acpica-unix/resources/rsutils.c | 2 +- .../dev/acpica-unix/resources/rsxface.c | 4 +- sys/contrib/dev/acpica-unix/tables/tbfadt.c | 27 +- sys/contrib/dev/acpica-unix/tables/tbfind.c | 4 +- sys/contrib/dev/acpica-unix/tables/tbinstal.c | 54 +- sys/contrib/dev/acpica-unix/tables/tbutils.c | 192 +- sys/contrib/dev/acpica-unix/tables/tbxface.c | 78 +- sys/contrib/dev/acpica-unix/tables/tbxfroot.c | 8 +- .../dev/acpica-unix/tools/acpiexec/Makefile | 793 +++++- .../dev/acpica-unix/tools/acpiexec/aecommon.h | 59 +- .../dev/acpica-unix/tools/acpiexec/aeexec.c | 323 ++- .../acpica-unix/tools/acpiexec/aehandlers.c | 373 ++- .../dev/acpica-unix/tools/acpiexec/aemain.c | 458 +++- .../dev/acpica-unix/tools/acpiexec/aetables.c | 387 +-- .../tools/acpiexec/{aetables.c => aetables.h} | 392 +-- .../acpica-unix/tools/acpiexec/osunixdir.c | 35 +- .../dev/acpica-unix/tools/acpisrc/Makefile | 2 +- .../dev/acpica-unix/tools/acpisrc/acpisrc.h | 9 +- .../dev/acpica-unix/tools/acpisrc/ascase.c | 42 +- .../dev/acpica-unix/tools/acpisrc/asconvrt.c | 20 +- .../dev/acpica-unix/tools/acpisrc/asfile.c | 13 +- .../dev/acpica-unix/tools/acpisrc/asmain.c | 20 +- .../dev/acpica-unix/tools/acpisrc/asremove.c | 2 +- .../dev/acpica-unix/tools/acpisrc/astable.c | 197 +- .../dev/acpica-unix/tools/acpisrc/asutils.c | 2 +- .../dev/acpica-unix/tools/acpisrc/osunixdir.c | 35 +- .../dev/acpica-unix/tools/acpixtract/Makefile | 2 +- .../acpica-unix/tools/acpixtract/acpixtract.c | 226 +- .../dev/acpica-unix/tools/examples/examples.c | 6 +- .../dev/acpica-unix/utilities/utalloc.c | 4 +- .../dev/acpica-unix/utilities/utcache.c | 2 +- .../dev/acpica-unix/utilities/utclib.c | 2 +- .../dev/acpica-unix/utilities/utcopy.c | 49 +- .../dev/acpica-unix/utilities/utdebug.c | 11 +- .../utilities/{utglobal.c => utdecode.c} | 353 +-- .../dev/acpica-unix/utilities/utdelete.c | 6 +- .../dev/acpica-unix/utilities/uteval.c | 542 +--- .../dev/acpica-unix/utilities/utglobal.c | 595 +--- sys/contrib/dev/acpica-unix/utilities/utids.c | 451 ++++ .../dev/acpica-unix/utilities/utinit.c | 30 +- .../dev/acpica-unix/utilities/utlock.c | 2 +- .../dev/acpica-unix/utilities/utmath.c | 58 +- .../dev/acpica-unix/utilities/utmisc.c | 187 +- .../dev/acpica-unix/utilities/utmutex.c | 55 +- .../dev/acpica-unix/utilities/utobject.c | 47 +- sys/contrib/dev/acpica-unix/utilities/utosi.c | 494 ++++ .../dev/acpica-unix/utilities/utresrc.c | 2 +- .../dev/acpica-unix/utilities/utstate.c | 4 +- .../dev/acpica-unix/utilities/uttrack.c | 127 +- .../dev/acpica-unix/utilities/utxface.c | 204 +- .../dev/acpica-unix/utilities/utxferror.c | 550 ++++ sys/dev/acpica5/Makefile | 12 +- sys/dev/acpica5/Osd/OsdHardware.c | 50 +- sys/dev/acpica5/acpi.c | 98 +- sys/dev/acpica5/acpi_button.c | 2 +- sys/dev/acpica5/acpi_cpu_cstate.c | 2 +- sys/dev/acpica5/acpi_ec.c | 19 +- sys/dev/acpica5/acpi_lid.c | 2 +- sys/dev/acpica5/acpi_pci.c | 2 +- sys/dev/acpica5/acpi_video/acpi_video.c | 2 +- sys/dev/acpica5/acpivar.h | 4 +- 293 files changed, 37251 insertions(+), 24560 deletions(-) create mode 100644 sys/contrib/dev/acpica-unix/common/dmextern.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslbtypes.c copy sys/contrib/dev/acpica-unix/compiler/{asltypes.h => aslmessages.h} (77%) create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslpredef.c copy sys/contrib/dev/acpica-unix/compiler/{aslrestype1.c => aslrestype1i.c} (55%) create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslrestype2d.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslrestype2e.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslrestype2q.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/aslrestype2w.c copy sys/contrib/dev/acpica-unix/{debugger/dbhistry.c => compiler/asluuid.c} (63%) copy sys/contrib/dev/acpica-unix/compiler/{aslanalyze.c => aslwalks.c} (52%) create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtcompile.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtcompiler.h create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtexpress.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtfield.c create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtio.c copy sys/contrib/dev/acpica-unix/{parser/psscope.c => compiler/dtsubtable.c} (56%) create mode 100644 sys/contrib/dev/acpica-unix/compiler/dttable.c copy sys/contrib/dev/acpica-unix/{events/evevent.c => compiler/dttemplate.c} (52%) create mode 100644 sys/contrib/dev/acpica-unix/compiler/dttemplate.h create mode 100644 sys/contrib/dev/acpica-unix/compiler/dtutils.c create mode 100644 sys/contrib/dev/acpica-unix/debugger/dbmethod.c create mode 100644 sys/contrib/dev/acpica-unix/debugger/dbnames.c create mode 100644 sys/contrib/dev/acpica-unix/dispatcher/dsargs.c create mode 100644 sys/contrib/dev/acpica-unix/dispatcher/dscontrol.c copy sys/contrib/dev/acpica-unix/dispatcher/{dswload.c => dswload2.c} (57%) create mode 100644 sys/contrib/dev/acpica-unix/events/evgpeinit.c copy sys/contrib/dev/acpica-unix/{utilities/utmutex.c => events/evgpeutil.c} (50%) copy sys/contrib/dev/acpica-unix/events/{evxfevnt.c => evxfgpe.c} (61%) copy sys/contrib/dev/acpica-unix/executer/{exstorob.c => exdebug.c} (54%) create mode 100644 sys/contrib/dev/acpica-unix/hardware/hwpci.c create mode 100644 sys/contrib/dev/acpica-unix/namespace/nsrepair.c create mode 100644 sys/contrib/dev/acpica-unix/namespace/nsrepair2.c copy sys/contrib/dev/acpica-unix/tools/acpiexec/{aetables.c => aetables.h} (52%) copy sys/contrib/dev/acpica-unix/utilities/{utglobal.c => utdecode.c} (63%) create mode 100644 sys/contrib/dev/acpica-unix/utilities/utids.c create mode 100644 sys/contrib/dev/acpica-unix/utilities/utosi.c create mode 100644 sys/contrib/dev/acpica-unix/utilities/utxferror.c diff --git a/sys/contrib/dev/acpica-unix/changes.txt b/sys/contrib/dev/acpica-unix/changes.txt index 89f6232614..b7e5387275 100644 --- a/sys/contrib/dev/acpica-unix/changes.txt +++ b/sys/contrib/dev/acpica-unix/changes.txt @@ -1,12 +1,1317 @@ ---------------------------------------- -21 May 2009. Summary of changes for version 20090521: +11 February 2011. Summary of changes for version 20110211: This release is available at www.acpica.org/downloads 1) ACPI CA Core Subsystem: +Added a mechanism to defer _REG methods for some early-installed handlers. +Most user handlers should be installed before call to AcpiEnableSubsystem. +However, Event handlers and region handlers should be installed after +AcpiInitializeObjects. Override handlers for the "default" regions should be +installed early, however. This change executes all _REG methods for the +default regions (Memory/IO/PCI/DataTable) simultaneously to prevent any +chicken/egg issues between them. ACPICA BZ 848. + +Implemented an optimization for GPE detection. This optimization will simply +ignore GPE registers that contain no enabled GPEs -- there is no need to +read the register since this information is available internally. This +becomes more important on machines with a large GPE space. ACPICA bugzilla +884. Lin Ming. Suggestion from Joe Liu. + +Removed all use of the highly unreliable FADT revision field. The revision +number in the FADT has been found to be completely unreliable and cannot be +trusted. Only the actual table length can be used to infer the version. This +change updates the ACPICA core and the disassembler so that both no longer +even look at the FADT version and instead depend solely upon the FADT +length. + +Fix an unresolved name issue for the no-debug and no-error-message source +generation cases. The _AcpiModuleName was left undefined in these cases, but +it is actually needed as a parameter to some interfaces. Define +_AcpiModuleName as a null string in these cases. ACPICA Bugzilla 888. + +Split several large files (makefiles and project files updated) + utglobal.c -> utdecode.c + dbcomds.c -> dbmethod.c dbnames.c + dsopcode.c -> dsargs.c dscontrol.c + dsload.c -> dsload2.c + aslanalyze.c -> aslbtypes.c aslwalks.c + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. + + Previous Release (VC 9.0): + Non-Debug Version: 89.7K Code, 23.7K Data, 113.4K Total + Debug Version: 163.9K Code, 67.5K Data, 231.4K Total + Current Release (VC 9.0): + Non-Debug Version: 89.7K Code, 23.7K Data, 113.4K Total + Debug Version: 163.9K Code, 67.5K Data, 231.4K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented the predefined macros __LINE__, __FILE__, and __DATE__. +These are useful C-style macros with the standard definitions. ACPICA +bugzilla 898. + +iASL/DTC: Added support for integer expressions and labels. Support for full +expressions for all integer fields in all ACPI tables. Support for labels in +"generic" portions of tables such as UEFI. See the iASL reference manual. + +Debugger: Added a command to display the status of global handlers. The +"handlers" command will display op region, fixed event, and miscellaneous +global handlers. installation status -- and for op regions, whether default +or user-installed handler will be used. + +iASL: Warn if reserved method incorrectly returns a value. Many predefined +names are defined such that they do not return a value. If implemented as a +method, issue a warning if such a name explicitly returns a value. ACPICA +Bugzilla 855. + +iASL: Added detection of GPE method name conflicts. Detects a conflict where +there are two GPE methods of the form _Lxy and _Exy in the same scope. (For +example, _L1D and _E1D in the same scope.) ACPICA bugzilla 848. + +iASL/DTC: Fixed a couple input scanner issues with comments and line +numbers. Comment remover could get confused and miss a comment ending. Fixed +a problem with line counter maintenance. + +iASL/DTC: Reduced the severity of some errors from fatal to error. There is +no need to abort on simple errors within a field definition. + +Debugger: Simplified the output of the help command. All help output now in +a single screen, instead of help subcommands. ACPICA Bugzilla 897. + + +---------------------------------------- +12 January 2011. Summary of changes for version 20110112: + +1) ACPI CA Core Subsystem: + +Fixed a race condition between method execution and namespace walks that can +possibly cause a fault. The problem was apparently introduced in version +20100528 as a result of a performance optimization that reduces the number +of +namespace walks upon method exit by using the delete_namespace_subtree +function instead of the delete_namespace_by_owner function used previously. +Bug is a missing namespace lock in the delete_namespace_subtree function. +dana.myers@oracle.com + +Fixed several issues and a possible fault with the automatic "serialized" +method support. History: This support changes a method to "serialized" on +the +fly if the method generates an AE_ALREADY_EXISTS error, indicating the +possibility that it cannot handle reentrancy. This fix repairs a couple of +issues seen in the field, especially on machines with many cores: + + 1) Delete method children only upon the exit of the last thread, + so as to not delete objects out from under other running threads + (and possibly causing a fault.) + 2) Set the "serialized" bit for the method only upon the exit of the + Last thread, so as to not cause deadlock when running threads + attempt to exit. + 3) Cleanup the use of the AML "MethodFlags" and internal method flags + so that there is no longer any confusion between the two. + + Lin Ming, Bob Moore. Reported by dana.myers@oracle.com. + +Debugger: Now lock the namespace for duration of a namespace dump. Prevents +issues if the namespace is changing dynamically underneath the debugger. +Especially affects temporary namespace nodes, since the debugger displays +these also. + +Updated the ordering of include files. The ACPICA headers should appear +before any compiler-specific headers (stdio.h, etc.) so that acenv.h can set +any necessary compiler-specific defines, etc. Affects the ACPI-related tools +and utilities. + +Updated all ACPICA copyrights and signons to 2011. Added the 2011 copyright +to all module headers and signons, including the Linux header. This affects +virtually every file in the ACPICA core subsystem, iASL compiler, and all +utilities. + +Added project files for MS Visual Studio 2008 (VC++ 9.0). The original +project files for VC++ 6.0 are now obsolete. New project files can be found +under acpica/generate/msvc9. See acpica/generate/msvc9/readme.txt for +details. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release (VC 6.0): + Non-Debug Version: 89.8K Code, 18.9K Data, 108.7K Total + Debug Version: 166.6K Code, 52.1K Data, 218.7K Total + Current Release (VC 9.0): + Non-Debug Version: 89.7K Code, 23.7K Data, 113.4K Total + Debug Version: 163.9K Code, 67.5K Data, 231.4K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Added generic data types to the Data Table compiler. Add "generic" +data +types such as UINT32, String, Unicode, etc., to simplify the generation of +platform-defined tables such as UEFI. Lin Ming. + +iASL: Added listing support for the Data Table Compiler. Adds listing +support +(-l) to display actual binary output for each line of input code. + +---------------------------------------- +09 December 2010. Summary of changes for version 20101209: + +1) ACPI CA Core Subsystem: + +Completed the major overhaul of the GPE support code that was begun in July +2010. Major features include: removal of _PRW execution in ACPICA (host +executes _PRWs anyway), cleanup of "wake" GPE interfaces and processing, +changes to existing interfaces, simplification of GPE handler operation, and +a handful of new interfaces: + + AcpiUpdateAllGpes + AcpiFinishGpe + AcpiSetupGpeForWake + AcpiSetGpeWakeMask + One new file, evxfgpe.c to consolidate all external GPE interfaces. + +See the ACPICA Programmer Reference for full details and programming +information. See the new section 4.4 "General Purpose Event (GPE) Support" +for a full overview, and section 8.7 "ACPI General Purpose Event Management" +for programming details. ACPICA BZ 858,870,877. Matthew Garrett, Lin Ming, +Bob Moore, Rafael Wysocki. + +Implemented a new GPE feature for Windows compatibility, the "Implicit Wake +GPE Notify". This feature will automatically issue a Notify(2) on a device +when a Wake GPE is received if there is no corresponding GPE method or +handler. ACPICA BZ 870. + +Fixed a problem with the Scope() operator during table parse and load phase. +During load phase (table load or method execution), the scope operator +should +not enter the target into the namespace. Instead, it should open a new scope +at the target location. Linux BZ 19462, ACPICA BZ 882. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 89.8K Code, 18.9K Data, 108.7K Total + Debug Version: 166.6K Code, 52.1K Data, 218.7K Total + Current Release: + Non-Debug Version: 89.9K Code, 19.0K Data, 108.9K Total + Debug Version: 166.3K Code, 52.1K Data, 218.4K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Relax the alphanumeric restriction on _CID strings. These strings are +"bus-specific" per the ACPI specification, and therefore any characters are +acceptable. The only checks that can be performed are for a null string and +perhaps for a leading asterisk. ACPICA BZ 886. + +iASL: Fixed a problem where a syntax error that caused a premature EOF +condition on the source file emitted a very confusing error message. The +premature EOF is now detected correctly. ACPICA BZ 891. + +Disassembler: Decode the AccessSize within a Generic Address Structure (byte +access, word access, etc.) Note, this field does not allow arbitrary bit +access, the size is encoded as 1=byte, 2=word, 3=dword, and 4=qword. + +New: AcpiNames utility - Example namespace dump utility. Shows an example of +ACPICA configuration for a minimal namespace dump utility. Uses table and +namespace managers, but no AML interpreter. Does not add any functionality +over AcpiExec, it is a subset of AcpiExec. The purpose is to show how to +partition and configure ACPICA. ACPICA BZ 883. + +AML Debugger: Increased the debugger buffer size for method return objects. +Was 4K, increased to 16K. Also enhanced error messages for debugger method +execution, including the buffer overflow case. + +---------------------------------------- +13 October 2010. Summary of changes for version 20101013: + +1) ACPI CA Core Subsystem: + +Added support to clear the PCIEXP_WAKE event. When clearing ACPI events, now +clear the PCIEXP_WAKE_STS bit in the ACPI PM1 Status Register, via +HwClearAcpiStatus. Original change from Colin King. ACPICA BZ 880. + +Changed the type of the predefined namespace object _TZ from ThermalZone to +Device. This was found to be confusing to the host software that processes +the various thermal zones, since _TZ is not really a ThermalZone. However, a +Notify() can still be performed on it. ACPICA BZ 876. Suggestion from Rui +Zhang. + +Added Windows Vista SP2 to the list of supported _OSI strings. The actual +string is "Windows 2006 SP2". + +Eliminated duplicate code in AcpiUtExecute* functions. Now that the nsrepair +code automatically repairs _HID-related strings, this type of code is no +longer needed in Execute_HID, Execute_CID, and Execute_UID. ACPICA BZ 878. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 89.9K Code, 19.0K Data, 108.9K Total + Debug Version: 166.3K Code, 52.1K Data, 218.4K Total + Current Release: + Non-Debug Version: 89.9K Code, 19.0K Data, 108.9K Total + Debug Version: 166.3K Code, 52.1K Data, 218.4K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented additional compile-time validation for _HID strings. The +non-hex prefix (such as "PNP" or "ACPI") must be uppercase, and the length +of +the string must be exactly seven or eight characters. For both _HID and _CID +strings, all characters must be alphanumeric. ACPICA BZ 874. + +iASL: Allow certain "null" resource descriptors. Some BIOS code creates +descriptors that are mostly or all zeros, with the expectation that they +will +be filled in at runtime. iASL now allows this as long as there is a +"resource +tag" (name) associated with the descriptor, which gives the ASL a handle +needed to modify the descriptor. ACPICA BZ 873. + +Added single-thread support to the generic Unix application OSL. Primarily +for iASL support, this change removes the use of semaphores in the single- +threaded ACPICA tools/applications - increasing performance. The +_MULTI_THREADED option was replaced by the (reverse) ACPI_SINGLE_THREADED +option. ACPICA BZ 879. + +AcpiExec: several fixes for the 64-bit version. Adds XSDT support and +support +for 64-bit DSDT/FACS addresses in the FADT. Lin Ming. + +iASL: Moved all compiler messages to a new file, aslmessages.h. + +---------------------------------------- +15 September 2010. Summary of changes for version 20100915: + +1) ACPI CA Core Subsystem: + +Removed the AcpiOsDerivePciId OSL interface. The various host +implementations +of this function were not OS-dependent and are now obsolete and can be +removed from all host OSLs. This function has been replaced by +AcpiHwDerivePciId, which is now part of the ACPICA core code. +AcpiHwDerivePciId has been implemented without recursion. Adds one new +module, hwpci.c. ACPICA BZ 857. + +Implemented a dynamic repair for _HID and _CID strings. The following +problems are now repaired at runtime: 1) Remove a leading asterisk in the +string, and 2) the entire string is uppercased. Both repairs are in +accordance with the ACPI specification and will simplify host driver code. +ACPICA BZ 871. + +The ACPI_THREAD_ID type is no longer configurable, internally it is now +always UINT64. This simplifies the ACPICA code, especially any printf +output. +UINT64 is the only common data type for all thread_id types across all +operating systems. It is now up to the host OSL to cast the native thread_id +type to UINT64 before returning the value to ACPICA (via AcpiOsGetThreadId). +Lin Ming, Bob Moore. + +Added the ACPI_INLINE type to enhance the ACPICA configuration. The "inline" +keyword is not standard across compilers, and this type allows inline to be +configured on a per-compiler basis. Lin Ming. + +Made the system global AcpiGbl_SystemAwakeAndRunning publically available. +Added an extern for this boolean in acpixf.h. Some hosts utilize this value +during suspend/restore operations. ACPICA BZ 869. + +All code that implements error/warning messages with the "ACPI:" prefix has +been moved to a new module, utxferror.c. + +The UINT64_OVERLAY was moved to utmath.c, which is the only module where it +is used. ACPICA BZ 829. Lin Ming, Bob Moore. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 89.1K Code, 19.0K Data, 108.1K Total + Debug Version: 165.1K Code, 51.9K Data, 217.0K Total + Current Release: + Non-Debug Version: 89.9K Code, 19.0K Data, 108.9K Total + Debug Version: 166.3K Code, 52.1K Data, 218.4K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL/Disassembler: Write ACPI errors to stderr instead of the output file. +This keeps the output files free of random error messages that may originate +from within the namespace/interpreter code. Used this opportunity to merge +all ACPI:-style messages into a single new module, utxferror.c. ACPICA BZ +866. Lin Ming, Bob Moore. + +Tools: update some printfs for ansi warnings on size_t. Handle width change +of size_t on 32-bit versus 64-bit generations. Lin Ming. + +---------------------------------------- +06 August 2010. Summary of changes for version 20100806: + +1) ACPI CA Core Subsystem: + +Designed and implemented a new host interface to the _OSI support code. This +will allow the host to dynamically add or remove multiple _OSI strings, as +well as install an optional handler that is called for each _OSI invocation. +Also added a new AML debugger command, 'osi' to display and modify the +global +_OSI string table, and test support in the AcpiExec utility. See the ACPICA +reference manual for full details. Lin Ming, Bob Moore. ACPICA BZ 836. +New Functions: + AcpiInstallInterface - Add an _OSI string. + AcpiRemoveInterface - Delete an _OSI string. + AcpiInstallInterfaceHandler - Install optional _OSI handler. +Obsolete Functions: + AcpiOsValidateInterface - no longer used. +New Files: + source/components/utilities/utosi.c + +Re-introduced the support to enable multi-byte transfers for Embedded +Controller (EC) operation regions. A reported problem was found to be a bug +in the host OS, not in the multi-byte support. Previously, the maximum data +size passed to the EC operation region handler was a single byte. There are +often EC Fields larger than one byte that need to be transferred, and it is +useful for the EC driver to lock these as a single transaction. This change +enables single transfers larger than 8 bits. This effectively changes the +access to the EC space from ByteAcc to AnyAcc, and will probably require +changes to the host OS Embedded Controller driver to enable 16/32/64/256-bit +transfers in addition to 8-bit transfers. Alexey Starikovskiy, Lin Ming. + +Fixed a problem with the prototype for AcpiOsReadPciConfiguration. The +prototype in acpiosxf.h had the output value pointer as a (void *). +It should be a (UINT64 *). This may affect some host OSL code. + +Fixed a couple problems with the recently modified Linux makefiles for iASL +and AcpiExec. These new makefiles place the generated object files in the +local directory so that there can be no collisions between the files that +are +shared between them that are compiled with different options. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 88.3K Code, 18.8K Data, 107.1K Total + Debug Version: 164.0K Code, 51.5K Data, 215.5K Total + Current Release: + Non-Debug Version: 89.1K Code, 19.0K Data, 108.1K Total + Debug Version: 165.1K Code, 51.9K Data, 217.0K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL/Disassembler: Added a new option (-da, "disassemble all") to load the +namespace from and disassemble an entire group of AML files. Useful for +loading all of the AML tables for a given machine (DSDT, SSDT1...SSDTn) and +disassembling with one simple command. ACPICA BZ 865. Lin Ming. + +iASL: Allow multiple invocations of -e option. This change allows multiple +uses of -e on the command line: "-e ssdt1.dat -e ssdt2.dat". ACPICA BZ 834. +Lin Ming. + +---------------------------------------- +02 July 2010. Summary of changes for version 20100702: + +1) ACPI CA Core Subsystem: + +Implemented several updates to the recently added GPE reference count +support. The model for "wake" GPEs is changing to give the host OS complete +control of these GPEs. Eventually, the ACPICA core will not execute any _PRW +methods, since the host already must execute them. Also, additional changes +were made to help ensure that the reference counts are kept in proper +synchronization with reality. Rafael J. Wysocki. + +1) Ensure that GPEs are not enabled twice during initialization. +2) Ensure that GPE enable masks stay in sync with the reference count. +3) Do not inadvertently enable GPEs when writing GPE registers. +4) Remove the internal wake reference counter and add new AcpiGpeWakeup +interface. This interface will set or clear individual GPEs for wakeup. +5) Remove GpeType argument from AcpiEnable and AcpiDisable. These interfaces +are now used for "runtime" GPEs only. + +Changed the behavior of the GPE install/remove handler interfaces. The GPE +is +no longer disabled during this process, as it was found to cause problems on +some machines. Rafael J. Wysocki. + +Reverted a change introduced in version 20100528 to enable Embedded +Controller multi-byte transfers. This change was found to cause problems +with +Index Fields and possibly Bank Fields. It will be reintroduced when these +problems have been resolved. + +Fixed a problem with references to Alias objects within Package Objects. A +reference to an Alias within the definition of a Package was not always +resolved properly. Aliases to objects like Processors, Thermal zones, etc. +were resolved to the actual object instead of a reference to the object as +it +should be. Package objects are only allowed to contain integer, string, +buffer, package, and reference objects. Redhat bugzilla 608648. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 88.3K Code, 18.8K Data, 107.1K Total + Debug Version: 164.1K Code, 51.5K Data, 215.6K Total + Current Release: + Non-Debug Version: 88.3K Code, 18.8K Data, 107.1K Total + Debug Version: 164.0K Code, 51.5K Data, 215.5K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented a new compiler subsystem to allow definition and +compilation of the non-AML ACPI tables such as FADT, MADT, SRAT, etc. These +are called "ACPI Data Tables", and the new compiler is the "Data Table +Compiler". This compiler is intended to simplify the existing error-prone +process of creating these tables for the BIOS, as well as allowing the +disassembly, modification, recompilation, and override of existing ACPI data +tables. See the iASL User Guide for detailed information. + +iASL: Implemented a new Template Generator option in support of the new Data +Table Compiler. This option will create examples of all known ACPI tables +that can be used as the basis for table development. See the iASL +documentation and the -T option. + +Disassembler and headers: Added support for the WDDT ACPI table (Watchdog +Descriptor Table). + +Updated the Linux makefiles for iASL and AcpiExec to place the generated +object files in the local directory so that there can be no collisions +between the shared files between them that are generated with different +options. + +Added support for Mac OS X in the Unix OSL used for iASL and AcpiExec. Use +the #define __APPLE__ to enable this support. + +---------------------------------------- +28 May 2010. Summary of changes for version 20100528: + +Note: The ACPI 4.0a specification was released on April 5, 2010 and is +available at www.acpi.info. This is primarily an errata release. + +1) ACPI CA Core Subsystem: + +Undefined ACPI tables: We are looking for the definitions for the following +ACPI tables that have been seen in the field: ATKG, IEIT, GSCI. + +Implemented support to enable multi-byte transfers for Embedded Controller +(EC) operation regions. Previously, the maximum data size passed to the EC +operation region handler was a single byte. There are often EC Fields larger +than one byte that need to be transferred, and it is useful for the EC +driver +to lock these as a single transaction. This change enables single transfers +larger than 8 bits. This effectively changes the access to the EC space from +ByteAcc to AnyAcc, and will probably require changes to the host OS Embedded +Controller driver to enable 16/32/64/256-bit transfers in addition to 8-bit +transfers. Alexey Starikovskiy, Lin Ming + +Implemented a performance enhancement for namespace search and access. This +change enhances the performance of namespace searches and walks by adding a +backpointer to the parent in each namespace node. On large namespaces, this +change can improve overall ACPI performance by up to 9X. Adding a pointer to +each namespace node increases the overall size of the internal namespace by +about 5%, since each namespace entry usually consists of both a namespace +node and an ACPI operand object. However, this is the first growth of the +namespace in ten years. ACPICA bugzilla 817. Alexey Starikovskiy. + +Implemented a performance optimization that reduces the number of namespace +walks. On control method exit, only walk the namespace if the method is +known +to have created namespace objects outside of its local scope. Previously, +the +entire namespace was traversed on each control method exit. This change can +improve overall ACPI performance by up to 3X. Alexey Starikovskiy, Bob +Moore. + +Added support to truncate I/O addresses to 16 bits for Windows +compatibility. +Some ASL code has been seen in the field that inadvertently has bits set +above bit 15. This feature is optional and is enabled if the BIOS requests +any Windows OSI strings. It can also be enabled by the host OS. Matthew +Garrett, Bob Moore. + +Added support to limit the maximum time for the ASL Sleep() operator. To +prevent accidental deep sleeps, limit the maximum time that Sleep() will +actually sleep. Configurable, the default maximum is two seconds. ACPICA +bugzilla 854. + +Added run-time validation support for the _WDG and_WED Microsoft predefined +methods. These objects are defined by "Windows Instrumentation", and are not +part of the ACPI spec. ACPICA BZ 860. + +Expanded all statistic counters used during namespace and device +initialization from 16 to 32 bits in order to support very large namespaces. + +Replaced all instances of %d in printf format specifiers with %u since +nearly +all integers in ACPICA are unsigned. + +Fixed the exception namestring for AE_WAKE_ONLY_GPE. Was incorrectly +returned +as AE_NO_HANDLER. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 88.4K Code, 18.8K Data, 107.2K Total + Debug Version: 164.2K Code, 51.5K Data, 215.7K Total + Current Release: + Non-Debug Version: 88.3K Code, 18.8K Data, 107.1K Total + Debug Version: 164.1K Code, 51.5K Data, 215.6K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Added compiler support for the _WDG and_WED Microsoft predefined +methods. These objects are defined by "Windows Instrumentation", and are not +part of the ACPI spec. ACPICA BZ 860. + +AcpiExec: added option to disable the memory tracking mechanism. The -dt +option will disable the tracking mechanism, which improves performance +considerably. + +AcpiExec: Restructured the command line options into -d (disable) and -e +(enable) options. + +---------------------------------------- +28 April 2010. Summary of changes for version 20100428: + +1) ACPI CA Core Subsystem: + +Implemented GPE support for dynamically loaded ACPI tables. For all GPEs, +including FADT-based and GPE Block Devices, execute any _PRW methods in the +new table, and process any _Lxx/_Exx GPE methods in the new table. Any +runtime GPE that is referenced by an _Lxx/_Exx method in the new table is +immediately enabled. Handles the FADT-defined GPEs as well as GPE Block +Devices. Provides compatibility with other ACPI implementations. Two new +files added, evgpeinit.c and evgpeutil.c. ACPICA BZ 833. Lin Ming, Bob +Moore. + +Fixed a regression introduced in version 20100331 within the table manager +where initial table loading could fail. This was introduced in the fix for +AcpiReallocateRootTable. Also, renamed some of fields in the table manager +data structures to clarify their meaning and use. + +Fixed a possible allocation overrun during internal object copy in +AcpiUtCopySimpleObject. The original code did not correctly handle the case +where the object to be copied was a namespace node. Lin Ming. ACPICA BZ 847. + +Updated the allocation dump routine, AcpiUtDumpAllocation and fixed a +possible access beyond end-of-allocation. Also, now fully validate +descriptor +(size and type) before output. Lin Ming, Bob Moore. ACPICA BZ 847 + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 87.9K Code, 18.6K Data, 106.5K Total + Debug Version: 163.5K Code, 51.3K Data, 214.8K Total + Current Release: + Non-Debug Version: 88.4K Code, 18.8K Data, 107.2K Total + Debug Version: 164.2K Code, 51.5K Data, 215.7K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented Min/Max/Len/Gran validation for address resource +descriptors. This change implements validation for the address fields that +are common to all address-type resource descriptors. These checks are +implemented: Checks for valid Min/Max, length within the Min/Max window, +valid granularity, Min/Max a multiple of granularity, and _MIF/_MAF as per +table 6-40 in the ACPI 4.0a specification. Also split the large +aslrestype1.c +and aslrestype2.c files into five new files. ACPICA BZ 840. + +iASL: Added support for the _Wxx predefined names. This support was missing +and these names were not recognized by the compiler as valid predefined +names. ACPICA BZ 851. + +iASL: Added an error for all predefined names that are defined to return no +value and thus must be implemented as Control Methods. These include all of +the _Lxx, _Exx, _Wxx, and _Qxx names, as well as some other miscellaneous +names such as _DIS, _INI, _IRC, _OFF, _ON, and _PSx. ACPICA BZ 850, 856. + +iASL: Implemented the -ts option to emit hex AML data in ASL format, as an +ASL Buffer. Allows ACPI tables to be easily included within ASL files, to be +dynamically loaded via the Load() operator. Also cleaned up output for the - +ta and -tc options. ACPICA BZ 853. + +Tests: Added a new file with examples of extended iASL error checking. +Demonstrates the advanced error checking ability of the iASL compiler. +Available at tests/misc/badcode.asl. + +---------------------------------------- +31 March 2010. Summary of changes for version 20100331: + +1) ACPI CA Core Subsystem: + +Completed a major update for the GPE support in order to improve support for +shared GPEs and to simplify both host OS and ACPICA code. Added a reference +count mechanism to support shared GPEs that require multiple device drivers. +Several external interfaces have changed. One external interface has been +removed. One new external interface was added. Most of the GPE external +interfaces now use the GPE spinlock instead of the events mutex (and the +Flags parameter for many GPE interfaces has been removed.) See the updated +ACPICA Programmer Reference for details. Matthew Garrett, Bob Moore, Rafael +Wysocki. ACPICA BZ 831. + +Changed: + AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus +Removed: + AcpiSetGpeType +New: + AcpiSetGpe + +Implemented write support for DataTable operation regions. These regions are +defined via the DataTableRegion() operator. Previously, only read support +was +implemented. The ACPI specification allows DataTableRegions to be +read/write, +however. + +Implemented a new subsystem option to force a copy of the DSDT to local +memory. Optionally copy the entire DSDT to local memory (instead of simply +mapping it.) There are some (albeit very rare) BIOSs that corrupt or replace +the original DSDT, creating the need for this option. Default is FALSE, do +not copy the DSDT. + +Implemented detection of a corrupted or replaced DSDT. This change adds +support to detect a DSDT that has been corrupted and/or replaced from +outside +the OS (by firmware). This is typically catastrophic for the system, but has +been seen on some machines. Once this problem has been detected, the DSDT +copy option can be enabled via system configuration. Lin Ming, Bob Moore. + +Fixed two problems with AcpiReallocateRootTable during the root table copy. +When copying the root table to the new allocation, the length used was +incorrect. The new size was used instead of the current table size, meaning +too much data was copied. Also, the count of available slots for ACPI tables +was not set correctly. Alexey Starikovskiy, Bob Moore. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 87.5K Code, 18.4K Data, 105.9K Total + Debug Version: 163.4K Code, 51.1K Data, 214.5K Total + Current Release: + Non-Debug Version: 87.9K Code, 18.6K Data, 106.5K Total + Debug Version: 163.5K Code, 51.3K Data, 214.8K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implement limited typechecking for values returned from predefined +control methods. The type of any returned static (unnamed) object is now +validated. For example, Return(1). ACPICA BZ 786. + +iASL: Fixed a predefined name object verification regression. Fixes a +problem +introduced in version 20100304. An error is incorrectly generated if a +predefined name is declared as a static named object with a value defined +using the keywords "Zero", "One", or "Ones". Lin Ming. + +iASL: Added Windows 7 support for the -g option (get local ACPI tables) by +reducing the requested registry access rights. ACPICA BZ 842. + +Disassembler: fixed a possible fault when generating External() statements. +Introduced in commit ae7d6fd: Properly handle externals with parent-prefix +(carat). Fixes a string length allocation calculation. Lin Ming. + +---------------------------------------- +04 March 2010. Summary of changes for version 20100304: + +1) ACPI CA Core Subsystem: + +Fixed a possible problem with the AML Mutex handling function +AcpiExReleaseMutex where the function could fault under the very rare +condition when the interpreter has blocked, the interpreter lock is +released, +the interpreter is then reentered via the same thread, and attempts to +acquire an AML mutex that was previously acquired. FreeBSD report 140979. +Lin +Ming. + +Implemented additional configuration support for the AML "Debug Object". +Output from the debug object can now be enabled via a global variable, +AcpiGbl_EnableAmlDebugObject. This will assist with remote machine +debugging. +This debug output is now available in the release version of ACPICA instead +of just the debug version. Also, the entire debug output module can now be +configured out of the ACPICA build if desired. One new file added, +executer/exdebug.c. Lin Ming, Bob Moore. + +Added header support for the ACPI MCHI table (Management Controller Host +Interface Table). This table was added in ACPI 4.0, but the defining +document +has only recently become available. + +Standardized output of integer values for ACPICA warnings/errors. Always use +0x prefix for hex output, always use %u for unsigned integer decimal output. +Affects ACPI_INFO, ACPI_ERROR, ACPI_EXCEPTION, and ACPI_WARNING (about 400 +invocations.) These invocations were converted from the original +ACPI_DEBUG_PRINT invocations and were not consistent. ACPICA BZ 835. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 87.1K Code, 18.0K Data, 105.1K Total + Debug Version: 163.5K Code, 50.9K Data, 214.4K Total + Current Release: + Non-Debug Version: 87.5K Code, 18.4K Data, 105.9K Total + Debug Version: 163.4K Code, 51.1K Data, 214.5K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented typechecking support for static (non-control method) +predefined named objects that are declared with the Name() operator. For +example, the type of this object is now validated to be of type Integer: +Name(_BBN, 1). This change migrates the compiler to using the core +predefined +name table instead of maintaining a local version. Added a new file, +aslpredef.c. ACPICA BZ 832. + +Disassembler: Added support for the ACPI 4.0 MCHI table. + +---------------------------------------- +21 January 2010. Summary of changes for version 20100121: + +1) ACPI CA Core Subsystem: + +Added the 2010 copyright to all module headers and signons. This affects +virtually every file in the ACPICA core subsystem, the iASL compiler, the +tools/utilities, and the test suites. + +Implemented a change to the AcpiGetDevices interface to eliminate +unnecessary +invocations of the _STA method. In the case where a specific _HID is +requested, do not run _STA until a _HID match is found. This eliminates +potentially dozens of _STA calls during a search for a particular +device/HID, +which in turn can improve boot times. ACPICA BZ 828. Lin Ming. + +Implemented an additional repair for predefined method return values. +Attempt +to repair unexpected NULL elements within returned Package objects. Create +an +Integer of value zero, a NULL String, or a zero-length Buffer as +appropriate. +ACPICA BZ 818. Lin Ming, Bob Moore. + +Removed the obsolete ACPI_INTEGER data type. This type was introduced as the +code was migrated from ACPI 1.0 (with 32-bit AML integers) to ACPI 2.0 (with +64-bit AML integers). It is now obsolete and this change removes it from the +ACPICA code base, replaced by UINT64. The original typedef has been retained +for now for compatibility with existing device driver code. ACPICA BZ 824. + +Removed the unused UINT32_STRUCT type, and the obsolete Integer64 field in +the parse tree object. + +Added additional warning options for the gcc-4 generation. Updated the +source +accordingly. This includes some code restructuring to eliminate unreachable +code, elimination of some gotos, elimination of unused return values, some +additional casting, and removal of redundant declarations. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 87.0K Code, 18.0K Data, 105.0K Total + Debug Version: 163.4K Code, 50.8K Data, 214.2K Total + Current Release: + Non-Debug Version: 87.1K Code, 18.0K Data, 105.1K Total + Debug Version: 163.5K Code, 50.9K Data, 214.4K Total + +2) iASL Compiler/Disassembler and Tools: + +No functional changes for this release. + +---------------------------------------- +14 December 2009. Summary of changes for version 20091214: + +1) ACPI CA Core Subsystem: + +Enhanced automatic data type conversions for predefined name repairs. This +change expands the automatic repairs/conversions for predefined name return +values to make Integers, Strings, and Buffers fully interchangeable. Also, a +Buffer can be converted to a Package of Integers if necessary. The +nsrepair.c +module was completely restructured. Lin Ming, Bob Moore. + +Implemented automatic removal of null package elements during predefined +name +repairs. This change will automatically remove embedded and trailing NULL +package elements from returned package objects that are defined to contain a +variable number of sub-packages. The driver is then presented with a package +with no null elements to deal with. ACPICA BZ 819. + +Implemented a repair for the predefined _FDE and _GTM names. The expected +return value for both names is a Buffer of 5 DWORDs. This repair fixes two +possible problems (both seen in the field), where a package of integers is +returned, or a buffer of BYTEs is returned. With assistance from Jung-uk +Kim. + +Implemented additional module-level code support. This change will properly +execute module-level code that is not at the root of the namespace (under a +Device object, etc.). Now executes the code within the current scope instead +of the root. ACPICA BZ 762. Lin Ming. + +Fixed possible mutex acquisition errors when running _REG methods. Fixes a +problem where mutex errors can occur when running a _REG method that is in +the same scope as a method-defined operation region or an operation region +under a module-level IF block. This type of code is rare, so the problem has +not been seen before. ACPICA BZ 826. Lin Ming, Bob Moore. + +Fixed a possible memory leak during module-level code execution. An object +could be leaked for each block of executed module-level code if the +interpreter slack mode is enabled This change deletes any implicitly +returned +object from the module-level code block. Lin Ming. + +Removed messages for successful predefined repair(s). The repair mechanism +was considered too wordy. Now, messages are only unconditionally emitted if +the return object cannot be repaired. Existing messages for successful +repairs were converted to ACPI_DEBUG_PRINT messages for now. ACPICA BZ 827. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 86.6K Code, 18.2K Data, 104.8K Total + Debug Version: 162.7K Code, 50.8K Data, 213.5K Total + Current Release: + Non-Debug Version: 87.0K Code, 18.0K Data, 105.0K Total + Debug Version: 163.4K Code, 50.8K Data, 214.2K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a regression introduced in 20091112 where intermediate .SRC +files +were no longer automatically removed at the termination of the compile. + +acpiexec: Implemented the -f option to specify default region fill value. +This option specifies the value used to initialize buffers that simulate +operation regions. Default value is zero. Useful for debugging problems that +depend on a specific initial value for a region or field. + +---------------------------------------- +12 November 2009. Summary of changes for version 20091112: + +1) ACPI CA Core Subsystem: + +Implemented a post-order callback to AcpiWalkNamespace. The existing +interface only has a pre-order callback. This change adds an additional +parameter for a post-order callback which will be more useful for bus scans. +ACPICA BZ 779. Lin Ming. Updated the ACPICA Programmer Reference. + +Modified the behavior of the operation region memory mapping cache for +SystemMemory. Ensure that the memory mappings created for operation regions +do not cross 4K page boundaries. Crossing a page boundary while mapping +regions can cause kernel warnings on some hosts if the pages have different +attributes. Such regions are probably BIOS bugs, and this is the workaround. +Linux BZ 14445. Lin Ming. + +Implemented an automatic repair for predefined methods that must return +sorted lists. This change will repair (by sorting) packages returned by +_ALR, +_PSS, and _TSS. Drivers can now assume that the packages are correctly +sorted +and do not contain NULL package elements. Adds one new file, +namespace/nsrepair2.c. ACPICA BZ 784. Lin Ming, Bob Moore. + +Fixed a possible fault during predefined name validation if a return Package +object contains NULL elements. Also adds a warning if a NULL element is +followed by any non-null elements. ACPICA BZ 813, 814. Future enhancement +may +include repair or removal of all such NULL elements where possible. + +Implemented additional module-level executable AML code support. This change +will execute module-level code that is not at the root of the namespace +(under a Device object, etc.) at table load time. Module-level executable +AML +code has been illegal since ACPI 2.0. ACPICA BZ 762. Lin Ming. + +Implemented a new internal function to create Integer objects. This function +simplifies miscellaneous object creation code. ACPICA BZ 823. + +Reduced the severity of predefined repair messages, Warning to Info. Since +the object was successfully repaired, a warning is too severe. Reduced to an +info message for now. These messages may eventually be changed to debug- +only. +ACPICA BZ 812. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 85.8K Code, 18.0K Data, 103.8K Total + Debug Version: 161.8K Code, 50.6K Data, 212.4K Total + Current Release: + Non-Debug Version: 86.6K Code, 18.2K Data, 104.8K Total + Debug Version: 162.7K Code, 50.8K Data, 213.5K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented Switch() with While(1) so that Break works correctly. This +change correctly implements the Switch operator with a surrounding While(1) +so that the Break operator works as expected. ACPICA BZ 461. Lin Ming. + +iASL: Added a message if a package initializer list is shorter than package +length. Adds a new remark for a Package() declaration if an initializer list +exists, but is shorter than the declared length of the package. Although +technically legal, this is probably a coding error and it is seen in the +field. ACPICA BZ 815. Lin Ming, Bob Moore. + +iASL: Fixed a problem where the compiler could fault after the maximum +number +of errors was reached (200). + +acpixtract: Fixed a possible warning for pointer cast if the compiler +warning +level set very high. + +---------------------------------------- +13 October 2009. Summary of changes for version 20091013: + +1) ACPI CA Core Subsystem: + +Fixed a problem where an Operation Region _REG method could be executed more +than once. If a custom address space handler is installed by the host before +the "initialize operation regions" phase of the ACPICA initialization, any +_REG methods for that address space could be executed twice. This change +fixes the problem. ACPICA BZ 427. Lin Ming. + +Fixed a possible memory leak for the Scope() ASL operator. When the exact +invocation of "Scope(\)" is executed (change scope to root), one internal +operand object was leaked. Lin Ming. + +Implemented a run-time repair for the _MAT predefined method. If the _MAT +return value is defined as a Field object in the AML, and the field +size is less than or equal to the default width of an integer (32 or +64),_MAT +can incorrectly return an Integer instead of a Buffer. ACPICA now +automatically repairs this problem. ACPICA BZ 810. + +Implemented a run-time repair for the _BIF and _BIX predefined methods. The +"OEM Information" field is often incorrectly returned as an Integer with +value zero if the field is not supported by the platform. This is due to an +ambiguity in the ACPI specification. The field should always be a string. +ACPICA now automatically repairs this problem by returning a NULL string +within the returned Package. ACPICA BZ 807. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 85.6K Code, 18.0K Data, 103.6K Total + Debug Version: 161.7K Code, 50.9K Data, 212.6K Total + Current Release: + Non-Debug Version: 85.8K Code, 18.0K Data, 103.8K Total + Debug Version: 161.8K Code, 50.6K Data, 212.4K Total + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Fixed a problem where references to external symbols that +contained one or more parent-prefixes (carats) were not handled correctly, +possibly causing a fault. ACPICA BZ 806. Lin Ming. + +Disassembler: Restructured the code so that all functions that handle +external symbols are in a single module. One new file is added, +common/dmextern.c. + +AML Debugger: Added a max count argument for the Batch command (which +executes multiple predefined methods within the namespace.) + +iASL: Updated the compiler documentation (User Reference.) Available at +http://www.acpica.org/documentation/. ACPICA BZ 750. + +AcpiXtract: Updated for Lint and other formatting changes. Close all open +files. + +---------------------------------------- +03 September 2009. Summary of changes for version 20090903: + +1) ACPI CA Core Subsystem: + +For Windows Vista compatibility, added the automatic execution of an _INI +method located at the namespace root (\_INI). This method is executed at +table load time. This support is in addition to the automatic execution of +\_SB._INI. Lin Ming. + +Fixed a possible memory leak in the interpreter for AML package objects if +the package initializer list is longer than the defined size of the package. +This apparently can only happen if the BIOS changes the package size on the +fly (seen in a _PSS object), as ASL compilers do not allow this. The +interpreter will truncate the package to the defined size (and issue an +error +message), but previously could leave the extra objects undeleted if they +were +pre-created during the argument processing (such is the case if the package +consists of a number of sub-packages as in the _PSS.) ACPICA BZ 805. + +Fixed a problem seen when a Buffer or String is stored to itself via ASL. +This has been reported in the field. Previously, ACPICA would zero out the +buffer/string. Now, the operation is treated as a noop. Provides Windows +compatibility. ACPICA BZ 803. Lin Ming. + +Removed an extraneous error message for ASL constructs of the form +Store(LocalX,LocalX) when LocalX is uninitialized. These curious statements +are seen in many BIOSs and are once again treated as NOOPs and no error is +emitted when they are encountered. ACPICA BZ 785. + +Fixed an extraneous warning message if a _DSM reserved method returns a +Package object. _DSM can return any type of object, so validation on the +return type cannot be performed. ACPICA BZ 802. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 85.5K Code, 18.0K Data, 103.5K Total + Debug Version: 161.6K Code, 50.9K Data, 212.5K Total + Current Release: + Non-Debug Version: 85.6K Code, 18.0K Data, 103.6K Total + Debug Version: 161.7K Code, 50.9K Data, 212.6K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a problem with the use of the Alias operator and Resource +Templates. The correct alias is now constructed and no error is emitted. +ACPICA BZ 738. + +iASL: Implemented the -I option to specify additional search directories for +include files. Allows multiple additional search paths for include files. +Directories are searched in the order specified on the command line (after +the local directory is searched.) ACPICA BZ 800. + +iASL: Fixed a problem where the full pathname for include files was not +emitted for warnings/errors. This caused the IDE support to not work +properly. ACPICA BZ 765. + +iASL: Implemented the -@ option to specify a Windows-style response file +containing additional command line options. ACPICA BZ 801. + +AcpiExec: Added support to load multiple AML files simultaneously (such as a +DSDT and multiple SSDTs). Also added support for wildcards within the AML +pathname. These features allow all machine tables to be easily loaded and +debugged together. ACPICA BZ 804. + +Disassembler: Added missing support for disassembly of HEST table Error Bank +subtables. + +---------------------------------------- +30 July 2009. Summary of changes for version 20090730: + +The ACPI 4.0 implementation for ACPICA is complete with this release. + +1) ACPI CA Core Subsystem: + +ACPI 4.0: Added header file support for all new and changed ACPI tables. +Completely new tables are: IBFT, IVRS, MSCT, and WAET. Tables that are new +for ACPI 4.0, but have previously been supported in ACPICA are: CPEP, BERT, +EINJ, ERST, and HEST. Other newly supported tables are: UEFI and WDAT. There +have been some ACPI 4.0 changes to other existing tables. Split the large +actbl1.h header into the existing actbl2.h header. ACPICA BZ 774. + +ACPI 4.0: Implemented predefined name validation for all new names. There +are +31 new names in ACPI 4.0. The predefined validation module was split into +two +files. The new file is namespace/nsrepair.c. ACPICA BZ 770. + +Implemented support for so-called "module-level executable code". This is +executable AML code that exists outside of any control method and is +intended +to be executed at table load time. Although illegal since ACPI 2.0, this +type +of code still exists and is apparently still being created. Blocks of this +code are now detected and executed as intended. Currently, the code blocks +must exist under either an If, Else, or While construct; these are the +typical cases seen in the field. ACPICA BZ 762. Lin Ming. + +Implemented an automatic dynamic repair for predefined names that return +nested Package objects. This applies to predefined names that are defined to +return a variable-length Package of sub-packages. If the number of sub- +packages is one, BIOS code is occasionally seen that creates a simple single +package with no sub-packages. This code attempts to fix the problem by +wrapping a new package object around the existing package. These methods can +be repaired: _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, and _TSS. ACPICA BZ +790. + +Fixed a regression introduced in 20090625 for the AcpiGetDevices interface. +The _HID/_CID matching was broken and no longer matched IDs correctly. +ACPICA +BZ 793. + +Fixed a problem with AcpiReset where the reset would silently fail if the +register was one of the protected I/O ports. AcpiReset now bypasses the port +validation mechanism. This may eventually be driven into the AcpiRead/Write +interfaces. + +Fixed a regression related to the recent update of the AcpiRead/Write +interfaces. A sleep/suspend could fail if the optional PM2 Control register +does not exist during an attempt to write the Bus Master Arbitration bit. +(However, some hosts already delete the code that writes this bit, and the +code may in fact be obsolete at this date.) ACPICA BZ 799. + +Fixed a problem where AcpiTerminate could fault if inadvertently called +twice +in succession. ACPICA BZ 795. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 84.7K Code, 17.8K Data, 102.5K Total + Debug Version: 160.5K Code, 50.6K Data, 211.1K Total + Current Release: + Non-Debug Version: 85.5K Code, 18.0K Data, 103.5K Total + Debug Version: 161.6K Code, 50.9K Data, 212.5K Total + +2) iASL Compiler/Disassembler and Tools: + +ACPI 4.0: Implemented disassembler support for all new ACPI tables and +changes to existing tables. ACPICA BZ 775. + +---------------------------------------- +25 June 2009. Summary of changes for version 20090625: + +The ACPI 4.0 Specification was released on June 16 and is available at +www.acpi.info. ACPICA implementation of ACPI 4.0 is underway and will +continue for the next few releases. + +1) ACPI CA Core Subsystem: + +ACPI 4.0: Implemented interpreter support for the IPMI operation region +address space. Includes support for bi-directional data buffers and an IPMI +address space handler (to be installed by an IPMI device driver.) ACPICA BZ +773. Lin Ming. + +ACPI 4.0: Added changes for existing ACPI tables - FACS and SRAT. Includes +support in both the header files and the disassembler. + +Completed a major update for the AcpiGetObjectInfo external interface. +Changes include: + - Support for variable, unlimited length HID, UID, and CID strings. + - Support Processor objects the same as Devices (HID,UID,CID,ADR,STA, etc.) + - Call the _SxW power methods on behalf of a device object. + - Determine if a device is a PCI root bridge. + - Change the ACPI_BUFFER parameter to ACPI_DEVICE_INFO. +These changes will require an update to all callers of this interface. See +the updated ACPICA Programmer Reference for details. One new source file has +been added - utilities/utids.c. ACPICA BZ 368, 780. + +Updated the AcpiRead and AcpiWrite external interfaces to support 64-bit +transfers. The Value parameter has been extended from 32 bits to 64 bits in +order to support new ACPI 4.0 tables. These changes will require an update +to +all callers of these interfaces. See the ACPICA Programmer Reference for +details. ACPICA BZ 768. + +Fixed several problems with AcpiAttachData. The handler was not invoked when +the host node was deleted. The data sub-object was not automatically deleted +when the host node was deleted. The interface to the handler had an unused +parameter, this was removed. ACPICA BZ 778. + +Enhanced the function that dumps ACPI table headers. All non-printable +characters in the string fields are now replaced with '?' (Signature, OemId, +OemTableId, and CompilerId.) ACPI tables with non-printable characters in +these fields are occasionally seen in the field. ACPICA BZ 788. + +Fixed a problem with predefined method repair code where the code that +attempts to repair/convert an object of incorrect type is only executed on +the first time the predefined method is called. The mechanism that disables +warnings on subsequent calls was interfering with the repair mechanism. +ACPICA BZ 781. + +Fixed a possible memory leak in the predefined validation/repair code when a +buffer is automatically converted to an expected string object. + +Removed obsolete 16-bit files from the distribution and from the current git +tree head. ACPICA BZ 776. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has +a +much larger code and data size. + + Previous Release: + Non-Debug Version: 83.4K Code, 17.5K Data, 100.9K Total + Debug Version: 158.9K Code, 50.0K Data, 208.9K Total + Current Release: + Non-Debug Version: 84.7K Code, 17.8K Data, 102.5K Total + Debug Version: 160.5K Code, 50.6K Data, 211.1K Total + +2) iASL Compiler/Disassembler and Tools: + +ACPI 4.0: iASL and Disassembler - implemented support for the new IPMI +operation region keyword. ACPICA BZ 771, 772. Lin Ming. + +ACPI 4.0: iASL - implemented compile-time validation support for all new +predefined names and control methods (31 total). ACPICA BZ 769. + +---------------------------------------- +21 May 2009. Summary of changes for version 20090521: + +1) ACPI CA Core Subsystem: + Disabled the preservation of the SCI enable bit in the PM1 control register. -The SCI enable bit (bit 0, SCI_EN) is defined by the ACPI specification to be +The SCI enable bit (bit 0, SCI_EN) is defined by the ACPI specification to +be a "preserved" bit - "OSPM always preserves this bit position", section 4.7.3.2.1. However, some machines fail if this bit is in fact preserved because the bit needs to be explicitly set by the OS as a workaround. No @@ -18,7 +1323,8 @@ incorrectly formed _PRT package could cause a fault. Added validation to ensure that each package element is actually a sub-package. Implemented a new interface to install or override a single control method, -AcpiInstallMethod. This interface is useful when debugging in order to repair +AcpiInstallMethod. This interface is useful when debugging in order to +repair an existing method or to install a missing method without having to override the entire ACPI table. See the ACPICA Programmer Reference for use and examples. Lin Ming, Bob Moore. @@ -32,7 +1338,8 @@ caller. Lin Ming. Fixed a problem with Mutex Sync Levels. Fixed a problem where if multiple mutexes of the same sync level are acquired but then not released in strict -opposite order, the internally maintained Current Sync Level becomes confused +opposite order, the internally maintained Current Sync Level becomes +confused and can cause subsequent execution errors. ACPICA BZ 471. Changed the allowable release order for ASL mutex objects. The ACPI 4.0 @@ -55,7 +1362,8 @@ and reduced code for this frequently used function. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -74,18 +1382,18 @@ after an invalid sub-table ID. ---------------------------------------- 22 April 2009. Summary of changes for version 20090422: -This release is available at www.acpica.org/downloads - 1) ACPI CA Core Subsystem: Fixed a compatibility issue with the recently released I/O port protection mechanism. For windows compatibility, 1) On a port protection violation, simply ignore the request and do not return an exception (allow the control method to continue execution.) 2) If only part of the request overlaps a -protected port, read/write the individual ports that are not protected. Linux +protected port, read/write the individual ports that are not protected. +Linux BZ 13036. Lin Ming -Enhanced the execution of the ASL/AML BreakPoint operator so that it actually +Enhanced the execution of the ASL/AML BreakPoint operator so that it +actually breaks into the AML debugger if the debugger is present. This matches the ACPI-defined behavior. @@ -98,12 +1406,14 @@ ACPICA BZ 766, 767. Fixed a number of possible warnings when compiling with gcc 4+ (depending on warning options.) Examples include printf formats, aliasing, unused globals, missing prototypes, missing switch default statements, use of non-ANSI -library functions, use of non-ANSI constructs. See generate/unix/Makefile for +library functions, use of non-ANSI constructs. See generate/unix/Makefile +for a list of warning options used with gcc 3 and 4. ACPICA BZ 735. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -115,10 +1425,12 @@ much larger code and data size. 2) iASL Compiler/Disassembler and Tools: -iASL: Fixed a generation warning from Bison 2.3 and fixed several warnings on +iASL: Fixed a generation warning from Bison 2.3 and fixed several warnings +on the 64-bit build. -iASL: Fixed a problem where the Unix/Linux versions of the compiler could not +iASL: Fixed a problem where the Unix/Linux versions of the compiler could +not correctly digest Windows/DOS formatted files (with CR/LF). iASL: Added a new option for "quiet mode" (-va) that produces only the @@ -146,8 +1458,10 @@ execute fully on Cygwin. 1) ACPI CA Core Subsystem: Fixed a possible race condition between AcpiWalkNamespace and dynamic table -unloads. Added a reader/writer locking mechanism to allow multiple concurrent -namespace walks (readers), but block a dynamic table unload until it can gain +unloads. Added a reader/writer locking mechanism to allow multiple +concurrent +namespace walks (readers), but block a dynamic table unload until it can +gain exclusive write access to the namespace. This fixes a problem where a table unload could (possibly catastrophically) delete the portion of the namespace that is currently being examined by a walk. Adds a new file, utlock.c, that @@ -181,7 +1495,8 @@ performed on a per-field basis instead of the entire region. Modified the handling of the PM1 Status Register ignored bit (bit 11.) Ignored bits must be "preserved" according to the ACPI spec. Usually, this means a read/modify/write when writing to the register. However, for status -registers, writing a one means clear the event. Writing a zero means preserve +registers, writing a one means clear the event. Writing a zero means +preserve the event (do not clear.) This behavior is clarified in the ACPI 4.0 spec, and the ACPICA code now simply always writes a zero to the ignored bit. @@ -221,7 +1536,8 @@ AcpiGetRegisterUnlocked function is no longer needed and has been removed. This will improve performance for reads on these registers. ACPICA BZ 760. Fixed the parameter validation for AcpiRead/Write. Now return -AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS if +AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS +if the register has an address of zero. Previously, these cases simply returned AE_OK. For optional registers such as PM1B status/enable/control, the caller should check for a valid register address before calling. ACPICA BZ 748. @@ -234,27 +1550,33 @@ and condensing duplicate code to reduce code size. Added new functions to transparently handle the possibly split PM1 A/B registers. AcpiHwReadMultiple and AcpiHwWriteMultiple. These two functions -now handle the split registers for PM1 Status, Enable, and Control. ACPICA BZ +now handle the split registers for PM1 Status, Enable, and Control. ACPICA +BZ 746. Added a function to handle the PM1 control registers, AcpiHwWritePm1Control. -This function writes both of the PM1 control registers (A/B). These registers +This function writes both of the PM1 control registers (A/B). These +registers are different than the PM1 A/B status and enable registers in that different values can be written to the A/B registers. Most notably, the SLP_TYP bits -can be different, as per the values returned from the _Sx predefined methods. +can be different, as per the values returned from the _Sx predefined +methods. Removed an extra register write within AcpiHwClearAcpiStatus. This function was writing an optional PM1B status register twice. The existing call to the low-level AcpiHwRegisterWrite automatically handles a possibly split PM1 A/B register. ACPICA BZ 751. -Split out the PM1 Status registers from the FADT. Added new globals for these +Split out the PM1 Status registers from the FADT. Added new globals for +these registers (A/B), similar to the way the PM1 Enable registers are handled. Instead of overloading the FADT Event Register blocks. This makes the code clearer and less prone to error. -Fixed the warning message for when the platform contains too many ACPI tables -for the default size of the global root table data structure. The calculation +Fixed the warning message for when the platform contains too many ACPI +tables +for the default size of the global root table data structure. The +calculation for the truncation value was incorrect. Removed the ACPI_GET_OBJECT_TYPE macro. Removed all instances of this @@ -269,13 +1591,15 @@ Conditionally compile the AcpiSetFirmwareWakingVector64 function. This function is only needed on 64-bit host operating systems and is thus not included for 32-bit hosts. -Debug output: print the input and result for invocations of the _OSI reserved +Debug output: print the input and result for invocations of the _OSI +reserved control method via the ACPI_LV_INFO debug level. Also, reduced some of the verbosity of this debug level. Len Brown. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -300,7 +1624,8 @@ virtually every file in the ACPICA core subsystem, the iASL compiler, and the tools/utilities. Implemented a change to allow the host to override any ACPI table, including -dynamically loaded tables. Previously, only the DSDT could be replaced by the +dynamically loaded tables. Previously, only the DSDT could be replaced by +the host. With this change, the AcpiOsTableOverride interface is called for each table found in the RSDT/XSDT during ACPICA initialization, and also whenever a table is dynamically loaded via the AML Load operator. @@ -313,7 +1638,8 @@ with the actual namespace entry which is itself padded with underscores. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -359,7 +1685,8 @@ file, components/hardware/hwxface.c Enhanced the FADT parsing and low-level ACPI register access: The ACPI register lengths within the FADT are now used, and the low level ACPI register access no longer hardcodes the ACPI register lengths. Given that -there may be some risk in actually trusting the FADT register lengths, a run- +there may be some risk in actually trusting the FADT register lengths, a +run- time option was added to fall back to the default hardcoded lengths if the FADT proves to contain incorrect values - UseDefaultRegisterWidths. This option is set to true for now, and a warning is issued if a suspicious FADT @@ -372,12 +1699,14 @@ Packages. Lin Ming. Added semaphore support to the Linux/Unix application OS-services layer (OSL). ACPICA BZ 448. Lin Ming. -Added the ACPI_MUTEX_TYPE configuration option to select whether mutexes will +Added the ACPI_MUTEX_TYPE configuration option to select whether mutexes +will be implemented in the OSL, or will binary semaphores be used instead. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -389,7 +1718,8 @@ much larger code and data size. 2) iASL Compiler/Disassembler and Tools: -iASL: Completed the '-e' option to include additional ACPI tables in order to +iASL: Completed the '-e' option to include additional ACPI tables in order +to aid with disassembly and External statement generation. ACPICA BZ 742. Lin Ming. @@ -406,7 +1736,8 @@ Disassembler: Updates for several ACPI data tables (HEST, EINJ, and MCFG). 1) ACPI CA Core Subsystem: -Restructured the ACPICA header files into public/private. acpi.h now includes +Restructured the ACPICA header files into public/private. acpi.h now +includes only the "public" acpica headers. All other acpica headers are "private" and should not be included by acpica users. One new file, accommon.h is used to include the commonly used private headers for acpica code generation. Future @@ -423,7 +1754,8 @@ with a valid null-terminated string. Linux BZ 11822. Updated the FACS waking vector interfaces. Split AcpiSetFirmwareWakingVector into two: one for the 32-bit vector, another for the 64-bit vector. This is required because the host OS must setup the wake much differently for each -vector (real vs. protected mode, etc.) and the interface itself should not be +vector (real vs. protected mode, etc.) and the interface itself should not +be deciding which vector to use. Also, eliminated the GetFirmwareWakingVector interface, as it served no purpose (only the firmware reads the vector, OS only writes the vector.) ACPICA BZ 731. @@ -464,13 +1796,15 @@ handler installation, and calling a control method. Available at source/tools/examples. Added a global pointer for FACS table to simplify internal FACS access. Use -the global pointer instead of using AcpiGetTableByIndex for each FACS access. +the global pointer instead of using AcpiGetTableByIndex for each FACS +access. This simplifies the code for the Global Lock and the Firmware Waking Vector(s). Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -483,7 +1817,8 @@ much larger code and data size. 2) iASL Compiler/Disassembler and Tools: iASL: Improved disassembly of external method calls. Added the -e option to -allow the inclusion of additional ACPI tables to help with the disassembly of +allow the inclusion of additional ACPI tables to help with the disassembly +of method invocations and the generation of external declarations during the disassembly. Certain external method invocations cannot be disassembled properly without the actual declaration of the method. Use the -e option to @@ -503,12 +1838,14 @@ references from the Alias operator itself. ACPICA BZ 738. 1) ACPI CA Core Subsystem: Designed and implemented a mechanism to validate predefined ACPI methods and -objects. This code validates the predefined ACPI objects (objects whose names +objects. This code validates the predefined ACPI objects (objects whose +names start with underscore) that appear in the namespace, at the time they are evaluated. The argument count and the type of the returned object are validated against the ACPI specification. The purpose of this validation is to detect problems with the BIOS-implemented predefined ACPI objects before -the results are returned to the ACPI-related drivers. Future enhancements may +the results are returned to the ACPI-related drivers. Future enhancements +may include actual repair of incorrect return objects where possible. Two new files are nspredef.c and acpredef.h. @@ -530,7 +1867,8 @@ similar in that they use a stack of state objects in order to eliminate recursion. The stack must be fully unwound and deallocated if an error occurs. Lin Ming. ACPICA BZ 383. -Removed the unused ACPI_BITREG_WAKE_ENABLE definition and entry in the global +Removed the unused ACPI_BITREG_WAKE_ENABLE definition and entry in the +global ACPI register table. This bit does not exist and is unused. Lin Ming, Bob Moore ACPICA BZ 442. @@ -541,7 +1879,8 @@ only incorrect, it could also be misleading. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -559,18 +1898,22 @@ much larger code and data size. Completed a major cleanup of the internal ACPI_OPERAND_OBJECT of type Reference. Changes include the elimination of cheating on the Object field for the DdbHandle subtype, addition of a reference class field to -differentiate the various reference types (instead of an AML opcode), and the +differentiate the various reference types (instead of an AML opcode), and +the cleanup of debug output for this object. Lin Ming, Bob Moore. BZ 723 Reduce an error to a warning for an incorrect method argument count. Previously aborted with an error if too few arguments were passed to a -control method via the external ACPICA interface. Now issue a warning instead +control method via the external ACPICA interface. Now issue a warning +instead and continue. Handles the case where the method inadvertently declares too many arguments, but does not actually use the extra ones. Applies mainly to the predefined methods. Lin Ming. Linux BZ 11032. -Disallow the evaluation of named object types with no intrinsic value. Return -AE_TYPE for objects that have no value and therefore evaluation is undefined: +Disallow the evaluation of named object types with no intrinsic value. +Return +AE_TYPE for objects that have no value and therefore evaluation is +undefined: Device, Event, Mutex, Region, Thermal, and Scope. Previously, evaluation of these types were allowed, but an exception would be generated at some point during the evaluation. Now, the error is generated up front. @@ -578,8 +1921,10 @@ during the evaluation. Now, the error is generated up front. Fixed a possible memory leak in the AcpiNsGetExternalPathname function (nsnames.c). Fixes a leak in the error exit path. -Removed the obsolete debug levels ACPI_DB_WARN and ACPI_DB_ERROR. These debug -levels were made obsolete by the ACPI_WARNING, ACPI_ERROR, and ACPI_EXCEPTION +Removed the obsolete debug levels ACPI_DB_WARN and ACPI_DB_ERROR. These +debug +levels were made obsolete by the ACPI_WARNING, ACPI_ERROR, and +ACPI_EXCEPTION interfaces. Also added ACPI_DB_EVENTS to correspond with the existing ACPI_LV_EVENTS. @@ -593,7 +1938,8 @@ compiler reference, and the changes.txt release logfile. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -623,18 +1969,17 @@ header. 29 July 2008. Summary of changes for version 20080729: -This release is available at http://acpica.org/downloads -Direct git access via http://www.acpica.org/repos/acpica.git - 1) ACPI CA Core Subsystem: Fix a possible deadlock in the GPE dispatch. Remove call to -AcpiHwDisableAllGpes during wake in AcpiEvGpeDispatch. This call will attempt +AcpiHwDisableAllGpes during wake in AcpiEvGpeDispatch. This call will +attempt to acquire the GPE lock but can deadlock since the GPE lock is already held at dispatch time. This code was introduced in version 20060831 as a response to Linux BZ 6881 and has since been removed from Linux. -Add a function to dereference returned reference objects. Examines the return +Add a function to dereference returned reference objects. Examines the +return object from a call to AcpiEvaluateObject. Any Index or RefOf references are automatically dereferenced in an attempt to return something useful (these reference types cannot be converted into an external ACPI_OBJECT.) Provides @@ -657,13 +2002,16 @@ The function could possibly fail when the caches are initialized. Yang Yi. Add a function to decode reference object types to strings. Created for improved error messages. -Improve object conversion error messages. Better error messages during object -conversion from internal to the external ACPI_OBJECT. Used for external calls +Improve object conversion error messages. Better error messages during +object +conversion from internal to the external ACPI_OBJECT. Used for external +calls to AcpiEvaluateObject. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -685,16 +2033,19 @@ appear in a disassembled ASL file if they were emitted by the original compiler. Instead of issuing an error or warning and forcing the user to manually change these names, issue a remark instead. -iASL: error if named object created in while loop. Emit an error if any named +iASL: error if named object created in while loop. Emit an error if any +named object is created within a While loop. If allowed, this code will generate a -run-time error on the second iteration of the loop when an attempt is made to +run-time error on the second iteration of the loop when an attempt is made +to create the same named object twice. ACPICA bugzilla 730. iASL: Support absolute pathnames for include files. Add support for absolute pathnames within the Include operator. previously, only relative pathnames were supported. -iASL: Enforce minimum 1 interrupt in interrupt macro and Resource Descriptor. +iASL: Enforce minimum 1 interrupt in interrupt macro and Resource +Descriptor. The ACPI spec requires one interrupt minimum. BZ 423 iASL: Handle a missing ResourceSource arg, with a present SourceIndex. @@ -706,18 +2057,17 @@ iASL: Prevent error message if CondRefOf target does not exist. Fixes cases where an error message is emitted if the target does not exist. BZ 516 iASL: Fix broken -g option (get Windows ACPI tables). Fixes the -g option -(get ACPI tables on Windows). This was apparently broken in version 20070919. +(get ACPI tables on Windows). This was apparently broken in version +20070919. -AcpiXtract: Handle EOF while extracting data. Correctly handle the case where +AcpiXtract: Handle EOF while extracting data. Correctly handle the case +where the EOF happens immediately after the last table in the input file. Print completion message. Previously, no message was displayed in this case. ---------------------------------------- 01 July 2008. Summary of changes for version 20080701: -This release is available at http://acpica.org/downloads -Direct git access via http://www.acpica.org/repos/acpica.git - 0) Git source tree / acpica.org Fixed a problem where a git-clone from http would not transfer the entire @@ -728,7 +2078,8 @@ source tree. Implemented a "careful" GPE disable in AcpiEvDisableGpe, only modify one enable bit. Now performs a read-change-write of the enable register instead of simply writing out the cached enable mask. This will prevent inadvertent -enabling of GPEs if a rogue GPE is received during initialization (before GPE +enabling of GPEs if a rogue GPE is received during initialization (before +GPE handlers are installed.) Implemented a copy for dynamically loaded tables. Previously, dynamically @@ -738,10 +2089,12 @@ OpRegion case, added checksum verify. Use the table length from the table header, not the region length. For the Buffer case, use the table length also. Dennis Noordsij, Bob Moore. BZ 10734 -Fixed a problem where the same ACPI table could not be dynamically loaded and +Fixed a problem where the same ACPI table could not be dynamically loaded +and unloaded more than once. Without this change, a table cannot be loaded again once it has been loaded/unloaded one time. The current mechanism does not -unregister a table upon an unload. During a load, if the same table is found, +unregister a table upon an unload. During a load, if the same table is +found, this no longer returns an exception. BZ 722 Fixed a problem where the wrong descriptor length was calculated for the @@ -751,7 +2104,8 @@ descriptor is 16 because of the round-up to 8 on the 64-bit build. Reported by Linn Crosetto. BZ 728 Fixed a possible memory leak in the Unload operator. The DdbHandle returned -by Load() did not have its reference count decremented during unload, leading +by Load() did not have its reference count decremented during unload, +leading to a memory leak. Lin Ming. BZ 727 Fixed a possible memory leak when deleting thermal/processor objects. Any @@ -759,7 +2113,8 @@ associated notify handlers (and objects) were not being deleted. Fiodor Suietov. BZ 506 Fixed the ordering of the ASCII names in the global mutex table to match the -actual mutex IDs. Used by AcpiUtGetMutexName, a function used for debug only. +actual mutex IDs. Used by AcpiUtGetMutexName, a function used for debug +only. Vegard Nossum. BZ 726 Enhanced the AcpiGetObjectInfo interface to return the number of required @@ -774,7 +2129,8 @@ Fixed an extraneous warning from exconfig.c on the 64-bit build. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -789,7 +2145,8 @@ much larger code and data size. iASL: Added two missing ACPI reserved names. Added _MTP and _ASZ, both resource descriptor names. -iASL: Detect invalid ASCII characters in input (windows version). Removed the +iASL: Detect invalid ASCII characters in input (windows version). Removed +the "-CF" flag from the flex compile, enables correct detection of non-ASCII characters in the input. BZ 441 @@ -797,9 +2154,12 @@ iASL: Eliminate warning when result of LoadTable is not used. Eliminate the "result of operation not used" warning when the DDB handle returned from LoadTable is not used. The warning is not needed. BZ 590 -AcpiExec: Add support for dynamic table load/unload. Now calls _CFG method to -pass address of table to the AML. Added option to disable OpRegion simulation -to allow creation of an OpRegion with a real address that was passed to _CFG. +AcpiExec: Add support for dynamic table load/unload. Now calls _CFG method +to +pass address of table to the AML. Added option to disable OpRegion +simulation +to allow creation of an OpRegion with a real address that was passed to +_CFG. All of this allows testing of the Load and Unload operators from AcpiExec. Debugger: update tables command for unloaded tables. Handle unloaded tables @@ -819,10 +2179,12 @@ Simplified the internal ACPI hardware interfaces to eliminate the locking flag parameter from Register Read/Write. Added a new external interface, AcpiGetRegisterUnlocked. -Fixed a problem where the invocation of a GPE control method could hang. This +Fixed a problem where the invocation of a GPE control method could hang. +This was a regression introduced in 20080514. The new method argument count validation mechanism can enter an infinite loop when a GPE method is -dispatched. Problem fixed by removing the obsolete code that passed GPE block +dispatched. Problem fixed by removing the obsolete code that passed GPE +block information to the notify handler via the control method parameter pointer. Fixed a problem where the _SST execution status was incorrectly returned to @@ -831,7 +2193,8 @@ the caller of AcpiEnterSleepStatePrep. This was a regression introduced in returned. BZ 716 Fixed a problem where a deleted object could be accessed from within the AML -parser. This was a regression introduced in version 20080123 as a fix for the +parser. This was a regression introduced in version 20080123 as a fix for +the Unload operator. Lin Ming. BZ 10669 Cleaned up the debug operand dump mechanism. Eliminated unnecessary operands @@ -852,7 +2215,8 @@ one mutex. Linn Crosetto Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -893,20 +2257,25 @@ the GPE, even if ACPICA thinks that that it is already disabled. It is possible that the AML or some other code has enabled the GPE unbeknownst to the ACPICA code. -Fixed a problem with the Field operator where zero-length fields would return -an AE_AML_NO_OPERAND exception during table load. Fix enables zero-length ASL +Fixed a problem with the Field operator where zero-length fields would +return +an AE_AML_NO_OPERAND exception during table load. Fix enables zero-length +ASL field declarations in Field(), BankField(), and IndexField(). BZ 10606. Implemented a fix for the Load operator, now load the table at the namespace root. This reverts a change introduced in version 20071019. The table is now loaded at the namespace root even though this goes against the ACPI specification. This provides compatibility with other ACPI implementations. -The ACPI specification will be updated to reflect this in ACPI 4.0. Lin Ming. +The ACPI specification will be updated to reflect this in ACPI 4.0. Lin +Ming. -Fixed a problem where ACPICA would not Load() tables with unusual signatures. +Fixed a problem where ACPICA would not Load() tables with unusual +signatures. Now ignore ACPI table signature for Load() operator. Only "SSDT" is acceptable to the ACPI spec, but tables are seen with OEMx and null sigs. -Therefore, signature validation is worthless. Apparently MS ACPI accepts such +Therefore, signature validation is worthless. Apparently MS ACPI accepts +such signatures, ACPICA must be compatible. BZ 10454. Fixed a possible negative array index in AcpiUtValidateException. Added NULL @@ -923,8 +2292,10 @@ many. This applies only to extern programmatic control method execution, not method-to-method calls within the AML. Lin Ming. Eliminated the ACPI_NATIVE_UINT type across all ACPICA code. This type is no -longer needed, especially with the removal of 16-bit support. It was replaced -mostly with UINT32, but also ACPI_SIZE where a type that changes 32/64 bit on +longer needed, especially with the removal of 16-bit support. It was +replaced +mostly with UINT32, but also ACPI_SIZE where a type that changes 32/64 bit +on 32/64-bit platforms is required. Added the C const qualifier for appropriate string constants -- mostly @@ -932,7 +2303,8 @@ MODULE_NAME and printf format strings. Jan Beulich. Example Code and Data Size: These are the sizes for the OS-independent acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The -debug version of the code includes the debug output trace mechanism and has a +debug version of the code includes the debug output trace mechanism and has +a much larger code and data size. Previous Release: @@ -956,7 +2328,8 @@ means 32-bit and this is unusual. 2 or greater is 64-bit. Implemented an additional change to the GPE support in order to suppress spurious or stray GPEs. The AcpiEvDisableGpe function will now permanently disable incoming GPEs that are neither enabled nor disabled -- meaning that -the GPE is unknown to the system. This should prevent future interrupt floods +the GPE is unknown to the system. This should prevent future interrupt +floods from that GPE. BZ 6217 (Zhang Rui) Fixed a problem where NULL package elements were not returned to the @@ -965,7 +2338,8 @@ instead of returning a NULL ACPI_OBJECT package element, potentially causing a buffer overflow and/or confusing the caller who expected a fixed number of elements. BZ 10132 (Lin Ming, Bob Moore) -Fixed a problem with the CreateField, CreateXXXField (Bit, Byte, Word, Dword, +Fixed a problem with the CreateField, CreateXXXField (Bit, Byte, Word, +Dword, Qword), Field, BankField, and IndexField operators when invoked from inside an executing control method. In this case, these operators created namespace nodes that were incorrectly left marked as permanent nodes instead of @@ -977,20 +2351,23 @@ Fixed a problem where the CreateField and CreateXXXField operators would incorrectly allow duplicate names (the name of the field) with no exception generated. -Implemented several changes for Notify handling. Added support for new Notify +Implemented several changes for Notify handling. Added support for new +Notify values (ACPI 2.0+) and improved the Notify debug output. Notify on PowerResource objects is no longer allowed, as per the ACPI specification. (Bob Moore, Zhang Rui) All Reference Objects returned via the AcpiEvaluateObject interface are now -marked as type "REFERENCE" instead of "ANY". The type ANY is now reserved for +marked as type "REFERENCE" instead of "ANY". The type ANY is now reserved +for NULL objects - either NULL package elements or unresolved named references. Fixed a problem where an extraneous debug message was produced for package objects (when debugging enabled). The message "Package List length larger than NumElements count" is now produced in the correct case, and is now an error message rather than a debug message. Added a debug message for the -opposite case, where NumElements is larger than the Package List (the package +opposite case, where NumElements is larger than the Package List (the +package will be padded out with NULL elements as per the ACPI spec.) Implemented several improvements for the output of the ASL "Debug" object to @@ -1028,7 +2405,8 @@ uses Switch as Serialized, thus preventing multiple thread entries. BZ 469. Implemented another MS compatibility design change for GPE/Notify handling. GPEs are now cleared/enabled asynchronously to allow all pending notifies to complete first. It is expected that the OSL will queue the enable request -behind all pending notify requests (may require changes to the local host OSL +behind all pending notify requests (may require changes to the local host +OSL in AcpiOsExecute). Alexey Starikovskiy. Fixed a problem where buffer and package objects passed as arguments to a @@ -1043,8 +2421,10 @@ returned from _CRS. This change affects the following resource descriptors: IRQ / IRQNoFlags and StartDependendentFn / StartDependentFnNoPri. (BZ 9487) Fixed a problem where a CopyObject to RegionField, BankField, and IndexField -objects did not perform an implicit conversion as it should. These types must -retain their initial type permanently as per the ACPI specification. However, +objects did not perform an implicit conversion as it should. These types +must +retain their initial type permanently as per the ACPI specification. +However, a CopyObject to all other object types should not perform an implicit conversion, as per the ACPI specification. (Lin Ming, Bob Moore) BZ 388 @@ -1052,7 +2432,8 @@ Fixed a problem with the AcpiGetDevices interface where the mechanism to match device CIDs did not examine the entire list of available CIDs, but instead aborted on the first non-matching CID. Andrew Patterson. -Fixed a regression introduced in version 20071114. The ACPI_HIDWORD macro was +Fixed a regression introduced in version 20071114. The ACPI_HIDWORD macro +was inadvertently changed to return a 16-bit value instead of a 32-bit value, truncating the upper dword of a 64-bit value. This macro is only used to display debug output, so no incorrect calculations were made. Also, @@ -1092,19 +2473,24 @@ the tools/utilities. Fixed a problem with the SizeOf operator when used with Package and Buffer objects. These objects have deferred execution for some arguments, and the -execution is now completed before the SizeOf is executed. This problem caused +execution is now completed before the SizeOf is executed. This problem +caused unexpected AE_PACKAGE_LIMIT errors on some systems (Lin Ming, Bob Moore) BZ 9558 -Implemented an enhancement to the interpreter "slack mode". In the absence of +Implemented an enhancement to the interpreter "slack mode". In the absence +of an explicit return or an implicitly returned object from the last executed -opcode, a control method will now implicitly return an integer of value 0 for +opcode, a control method will now implicitly return an integer of value 0 +for Microsoft compatibility. (Lin Ming) BZ 392 -Fixed a problem with the Load operator where an exception was not returned in +Fixed a problem with the Load operator where an exception was not returned +in the case where the table is already loaded. (Lin Ming) BZ 463 -Implemented support for the use of DDBHandles as an Indexed Reference, as per +Implemented support for the use of DDBHandles as an Indexed Reference, as +per the ACPI spec. (Lin Ming) BZ 486 Implemented support for UserTerm (Method invocation) for the Unload operator @@ -1117,7 +2503,8 @@ maximum lengths allowed. (Lin Ming, Bob Moore) BZ 576 Implemented support for UserTerm (Method invocation) for the Unload operator as per the ACPI spec. (Lin Ming) BZ 580 -Implemented header file support for new ACPI tables - BERT, ERST, EINJ, HEST, +Implemented header file support for new ACPI tables - BERT, ERST, EINJ, +HEST, IBFT, UEFI, WDAT. Disassembler support is forthcoming. Example Code and Data Size: These are the sizes for the OS-independent @@ -1135,7 +2522,8 @@ a much larger code and data size. 2) iASL Compiler/Disassembler and Tools: Implemented support in the disassembler for checksum validation on incoming -binary DSDTs and SSDTs. If incorrect, a message is displayed within the table +binary DSDTs and SSDTs. If incorrect, a message is displayed within the +table header dump at the start of the disassembly. Implemented additional debugging information in the namespace listing file @@ -1162,7 +2550,8 @@ Ming) BZ 583,587 Implemented full support for deferred execution for the TermArg string arguments for DataTableRegion. This enables forward references and full -operand resolution for the three string arguments. Similar to OperationRegion +operand resolution for the three string arguments. Similar to +OperationRegion deferred argument execution.) Lin Ming. BZ 430 Implemented full argument resolution support for the BankValue argument to @@ -1177,7 +2566,8 @@ Zhao. Fixed a problem where "unknown" GPEs could be allowed to fire repeatedly if the underlying AML code changed the GPE enable registers. Now, any unknown -incoming GPE (no _Lxx/_Exx method and not the EC GPE) is immediately disabled +incoming GPE (no _Lxx/_Exx method and not the EC GPE) is immediately +disabled instead of simply ignored. Rui Zhang. Fixed a problem with Index Fields where the Index register was incorrectly diff --git a/sys/contrib/dev/acpica-unix/common/16bit.h b/sys/contrib/dev/acpica-unix/common/16bit.h index 131b5621a7..e69de29bb2 100644 --- a/sys/contrib/dev/acpica-unix/common/16bit.h +++ b/sys/contrib/dev/acpica-unix/common/16bit.h @@ -1,165 +0,0 @@ -/****************************************************************************** - * - * Module Name: 16bit.h - 16-bit support - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define GET_SEGMENT(ptr) ((UINT16)(_segment)(ptr)) -#define GET_OFFSET(ptr) ((UINT16)(UINT32) (ptr)) -#define GET_PHYSICAL_ADDRESS(ptr) (((((UINT32)GET_SEGMENT(ptr)) << 4)) + GET_OFFSET(ptr)) -#define PTR_OVL_BUILD_PTR(p,b,o) {p.ovl.base=b;p.ovl.offset=o;} - -typedef union ptr_ovl -{ - void *ptr; - UINT32 dword; - struct - { - UINT16 offset; - UINT16 base; - } ovl; - -} PTR_OVL; - - -int ACPI_INTERNAL_VAR_XFACE -FlatMove ( - UINT32 Dest, - UINT32 Src, - UINT16 Size); - -int ACPI_INTERNAL_VAR_XFACE -FlatMove32 ( - UINT32 Dest, - UINT32 Src, - UINT16 Size); - -ACPI_NATIVE_INT -AfWriteBuffer ( - char *Filename, - char *Buffer, - UINT32 Length); - -char * -AfGenerateFilename (char *TableId); - - -ACPI_STATUS -AfFindTable( - char *TableName, - UINT8 **TablePtr, - UINT32 *TableLength); - -void -AfDumpTables (void); - diff --git a/sys/contrib/dev/acpica-unix/common/a16find.c b/sys/contrib/dev/acpica-unix/common/a16find.c index 22b7f2ed35..e69de29bb2 100644 --- a/sys/contrib/dev/acpica-unix/common/a16find.c +++ b/sys/contrib/dev/acpica-unix/common/a16find.c @@ -1,962 +0,0 @@ -/****************************************************************************** - * - * Module Name: a16find - 16-bit (real mode) routines to find ACPI - * tables in memory - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States 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 "acpi.h" -#include "accommon.h" -#include "amlcode.h" -#include "acparser.h" -#include "actables.h" - -#include "16bit.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("a16find") - -/* - * This module finds ACPI tables located in memory. - * It is only generated for the 16-bit (real-mode) version of the utility. - */ - -#define ACPI_TABLE_FILE_SUFFIX ".dat" - - -#if ACPI_MACHINE_WIDTH == 16 - -UINT32 ACPI_INTERNAL_VAR_XFACE dIn32 (UINT16 port); -void ACPI_INTERNAL_VAR_XFACE vOut32 (UINT16 port, UINT32 Val); -#define ACPI_ENABLE_HPET 0x00020000 - -char FilenameBuf[20]; -ACPI_TABLE_HEADER AcpiTblHeader; -UINT32 TableSize; - -UINT32 AcpiGbl_SystemFlags; -UINT32 AcpiGbl_RsdpOriginalLocation; - -#if 0 -/****************************************************************************** - * - * FUNCTION: AfWriteBuffer - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Open a file and write out a single buffer - * - ******************************************************************************/ - -ACPI_NATIVE_INT -AfWriteBuffer ( - char *Filename, - char *Buffer, - UINT32 Length) -{ - FILE *fp; - ACPI_NATIVE_INT Actual; - - - fp = fopen (Filename, "wb"); - if (!fp) - { - printf ("Couldn't open %s\n", Filename); - return -1; - } - - Actual = fwrite (Buffer, (size_t) Length, 1, fp); - fclose (fp); - return Actual; -} - - -/****************************************************************************** - * - * FUNCTION: AfGenerateFilename - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Build an output filename from an ACPI table ID string - * - ******************************************************************************/ - -char * -AfGenerateFilename (char *TableId) -{ - UINT16 i; - - - for (i = 0; i < 8 && TableId[i] != ' ' && TableId[i] != 0; i++) - { - FilenameBuf [i] = TableId[i]; - } - - FilenameBuf [i] = 0; - strcat (FilenameBuf, ACPI_TABLE_FILE_SUFFIX); - return FilenameBuf; -} - - -/****************************************************************************** - * - * FUNCTION: AfDumpTables - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Dump the loaded tables to a file (or files) - * - ******************************************************************************/ - -void -AfDumpTables (void) -{ - char *Filename; - - - if (!AcpiGbl_DSDT) - { - AcpiOsPrintf ("No DSDT!\n"); - return; - } - - - Filename = AfGenerateFilename (AcpiGbl_DSDT->OemTableId); - AfWriteBuffer (Filename, - (char *) AcpiGbl_DSDT, AcpiGbl_DSDT->Length); - - AcpiOsPrintf ("DSDT AML written to \"%s\"\n", Filename); -} - -#endif - -void pascal -cprint ( - UINT32 value) -{ - - AcpiOsPrintf ("Seq: 0x%8.8X\n", value); -} - - -/****************************************************************************** - * - * FUNCTION: CopyExtendedToReal - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Copy memory above 1meg - * - ******************************************************************************/ - -int -CopyExtendedToReal ( - void *Destination, - UINT32 PhysicalSource, - UINT32 Size) -{ - int RetVal; - - - RetVal = FlatMove32 (GET_PHYSICAL_ADDRESS (Destination), - PhysicalSource, (UINT16) Size); - - AcpiOsPrintf ("FlatMove return: 0x%hX From %X To %X Len %X\n", - (int) RetVal, PhysicalSource, GET_PHYSICAL_ADDRESS (Destination), Size); - return (RetVal); -} - - -/****************************************************************************** - * - * FUNCTION: AfFindRsdp - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Scan memory to find the RSDP - * - ******************************************************************************/ - -BOOLEAN -AfFindRsdp (RSDP_DESCRIPTOR **RSDP) -{ - PTR_OVL Rove; - - - PTR_OVL_BUILD_PTR (Rove, 0, 0); - - - /* Scan low memory */ - - do - { - if (strncmp (Rove.ptr, ACPI_SIG_RSDP, (size_t) 8) == 0) - { - - /* TBD: Checksum check is invalid for X descriptor */ - -/* if (AcpiTbSumTable (Rove.ptr, sizeof(RSDP_DESCRIPTOR)) != 0) - { - */ - AcpiOsPrintf ("RSDP found at %p (Lo block)\n", Rove.ptr); - *RSDP = Rove.ptr; - return (TRUE); - } - - Rove.ovl.base++; - } - while (Rove.ovl.base < 0x3F); - - /* Scan high memory */ - - PTR_OVL_BUILD_PTR (Rove, 0xE000, 0); - do - { - if (strncmp (Rove.ptr, ACPI_SIG_RSDP, (size_t) 8) == 0) - { - AcpiOsPrintf ("RSDP found at %p (Hi block)\n", Rove.ptr); - *RSDP = Rove.ptr; - return (TRUE); - } - - Rove.ovl.base++; - } - while (Rove.ovl.base < 0xFFFF); - - return (FALSE); -} - - -/****************************************************************************** - * - * FUNCTION: AfRecognizeTable - * - * 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 - * - ******************************************************************************/ - -ACPI_STATUS -AfRecognizeTable ( - char *TablePtr, - UINT32 PhysAddr, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_TABLE_HEADER *TableHeader; - ACPI_STATUS Status; - ACPI_TABLE_TYPE TableType = 0; - void **TableGlobalPtr; - UINT32 i; - - - ACPI_FUNCTION_TRACE (AfRecognizeTable); - - - /* 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 */ - - Status = AE_SUPPORT; - for (i = 1; i < NUM_ACPI_TABLE_TYPES; i++) /* Start at one -> Skip RSDP */ - { - if (!ACPI_STRNCMP (TableHeader->Signature, - AcpiGbl_TableData[i].Signature, - AcpiGbl_TableData[i].SigLength)) - { - AcpiOsPrintf ("Found table [%s] Length 0x%X\n", - AcpiGbl_TableData[i].Signature, (UINT32) TableHeader->Length); - - TableType = i; - TableGlobalPtr = AcpiGbl_TableData[i].GlobalPtr; - Status = AE_OK; - break; - } - } - - /* Return the table type via the info struct */ - - TableInfo->Type = (UINT8) TableType; - TableInfo->Length = (ACPI_SIZE) TableHeader->Length; - - /* - * An AE_SUPPORT means that the table was not recognized. - * We ignore this table; just print a debug message - */ - if (Status == AE_SUPPORT) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Unsupported table %s (Type %d) was found and discarded\n", - AcpiGbl_TableData[TableType].Name, (UINT32) TableType)); - - return_ACPI_STATUS (Status); - } - - Status = AcpiTbValidateTableHeader (TableHeader); - if (ACPI_FAILURE (Status)) - { - /* Table failed verification, map all errors to BAD_DATA */ - - ACPI_ERROR ((AE_INFO, - "Invalid table header found in table named %s (Type %d)", - AcpiGbl_TableData[TableType].Name, (UINT32) TableType)); - - return_ACPI_STATUS (AE_BAD_DATA); - } - - /* Now get the rest of the table */ - - *TableGlobalPtr = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!*TableGlobalPtr) - { - AcpiOsPrintf ( - "Could not allocate buffer for Acpi table of length 0x%X\n", - (UINT32) ((FACS_DESCRIPTOR *) &AcpiTblHeader)->Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - TableInfo->Pointer = *TableGlobalPtr; - - CopyExtendedToReal (*TableGlobalPtr, PhysAddr, AcpiTblHeader.Length); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s=%p, (TableGlobalPtr=%p)\n", - AcpiGbl_TableData[TableType].Signature, - *TableGlobalPtr, TableGlobalPtr)); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer (*TableGlobalPtr, 48, 0, 0); - } - - /* - * 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: make this a configuration option? */ - - AcpiTbVerifyTableChecksum (*TableGlobalPtr); - } - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AfGetAllTables - * - * PARAMETERS: Root - Root of the parse tree - * - * RETURN: None - * - * DESCRIPTION: - * - *****************************************************************************/ - -ACPI_STATUS -AfGetAllTables ( - UINT32 NumberOfTables, - char *TablePtr) -{ - ACPI_STATUS Status = AE_OK; - UINT32 Index; - ACPI_TABLE_DESC TableInfo; - - - ACPI_FUNCTION_TRACE (AfGetAllTables); - - - if (AcpiGbl_DbOpt_verbose) - { - AcpiOsPrintf ("Number of tables: %d\n", (UINT32) 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++) - { - /* Get the table via the RSDT */ - - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]), - sizeof (ACPI_TABLE_HEADER)); - - TableInfo.Pointer = &AcpiTblHeader; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Table pointer: %X\n", - (UINT32) ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]))); - - Status = AfRecognizeTable (NULL, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]), &TableInfo); - if (ACPI_SUCCESS (Status)) - { - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - } - - /* Ignore errors, just move on to next table */ - } - - if (!AcpiGbl_FADT) - { - AcpiOsPrintf ("FADT was not found, cannot obtain FACS and DSDT!\n"); - return (AE_NO_ACPI_TABLES); - } - - Status = AcpiTbConvertTableFadt (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Get the FACS - */ - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), - sizeof (ACPI_TABLE_HEADER)); - AcpiGbl_FACS = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!AcpiGbl_FACS) - { - AcpiOsPrintf ("Could not allocate buffer for FADT length 0x%X\n", - (UINT32) AcpiTblHeader.Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - CopyExtendedToReal (AcpiGbl_FACS, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), AcpiTblHeader.Length); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FACS at %p (Phys %8.8X) length %X FADT at%p\n", - AcpiGbl_FACS, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), - (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT)); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_FADT, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - TableInfo.Type = ACPI_TABLE_FADT; - TableInfo.Pointer = (void *) AcpiGbl_FADT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - /* There is no checksum for the FACS, nothing to verify */ - - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - - AcpiTbBuildCommonFacs (&TableInfo); - - /* - * Get the DSDT - */ - CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), sizeof (ACPI_TABLE_HEADER)); - AcpiGbl_DSDT = ACPI_ALLOCATE (AcpiTblHeader.Length); - if (!AcpiGbl_DSDT) - { - AcpiOsPrintf ("Could not allocate buffer for DSDT length 0x%X\n", (UINT32) AcpiTblHeader.Length); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - CopyExtendedToReal (AcpiGbl_DSDT, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), AcpiTblHeader.Length); - - AcpiOsPrintf ("DSDT at %p (Phys %8.8X) length %X FADT at %p\n", - AcpiGbl_DSDT, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), - (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - TableInfo.Type = ACPI_TABLE_DSDT; - TableInfo.Pointer = (void *) AcpiGbl_DSDT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo); - AcpiTbVerifyTableChecksum ((ACPI_TABLE_HEADER *) AcpiGbl_DSDT); - - return_ACPI_STATUS (AE_OK); -} - - -ACPI_STATUS -AfGetRsdt (void) -{ - BOOLEAN Found; - UINT32 PhysicalAddress; - UINT32 SignatureLength; - char *TableSignature; - ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; - - - ACPI_FUNCTION_TRACE (AfGetRsdt); - - if (AcpiGbl_XSDT) - { - return (AE_OK); - } - - Found = AfFindRsdp (&AcpiGbl_RSDP); - if (!Found) - { - AcpiOsPrintf ("Could not find RSDP in the low megabyte\n"); - return (AE_NO_ACPI_TABLES); - } - - /* Use XSDT if it is present */ - - if ((AcpiGbl_RSDP->Revision >= 2) && - ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress)) - { - PhysicalAddress = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); - TableSignature = ACPI_SIG_XSDT; - SignatureLength = sizeof (ACPI_SIG_XSDT) -1; - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_XSDT; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found XSDT\n")); - } - else - { - /* No XSDT, use the RSDT */ - - PhysicalAddress = AcpiGbl_RSDP->RsdtPhysicalAddress; - TableSignature = ACPI_SIG_RSDT; - SignatureLength = sizeof (ACPI_SIG_RSDT) -1; - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_RSDT; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found RSDT\n")); - } - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) AcpiGbl_RSDP, sizeof (RSDP_DESCRIPTOR), 0, ACPI_UINT32_MAX); - } - - /* Get the RSDT/XSDT header to determine the table length */ - - CopyExtendedToReal (&AcpiTblHeader, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDT/XSDT at %8.8X\n", (UINT32) PhysicalAddress)); - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, ACPI_UINT32_MAX); - } - - /* Validate the table header */ - - Status = AcpiTbValidateTableHeader (&AcpiTblHeader); - if (ACPI_FAILURE (Status)) - { - /* Table failed verification, map all errors to BAD_DATA */ - - ACPI_ERROR ((AE_INFO, "Invalid RSDT table header")); - return (AE_BAD_DATA); - } - - /* Allocate a buffer for the entire table */ - - AcpiGbl_XSDT = (void *) malloc ((size_t) AcpiTblHeader.Length); - if (!AcpiGbl_XSDT) - { - AcpiOsPrintf ("Could not allocate buffer for RSDT length 0x%X\n", - (UINT32) AcpiTblHeader.Length); - return AE_NO_MEMORY; - } - - /* Get the entire RSDT/XSDT */ - - CopyExtendedToReal (AcpiGbl_XSDT, PhysicalAddress, AcpiTblHeader.Length); - AcpiOsPrintf ("%s at %p (Phys %8.8X)\n", - TableSignature, AcpiGbl_XSDT, (UINT32) PhysicalAddress); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - /* Convert to common format XSDT */ - - TableInfo.Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_XSDT; - TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer); - - Status = AcpiTbConvertToXsdt (&TableInfo); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer; - -ErrorExit: - return (Status); -} - - -void -AfDumpRsdt (void) -{ - UINT32 i; - UINT32 NumTables; - UINT32 PhysicalAddress; - ACPI_TABLE_HEADER **Table; - ACPI_TABLE_HEADER ThisTable; - - - NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8; - - AcpiOsPrintf ("%d Tables defined in RSDT/XSDT:\n", NumTables); - - for (i = 0; i < NumTables; i++) - { - PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo; - CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - AcpiOsPrintf ("[%4.4s] ", ThisTable.Signature); - ((char *) Table) += 8; - } - - AcpiOsPrintf ("\n"); -} - -ACPI_STATUS -AfGetTable ( - ACPI_TABLE_HEADER *TableHeader, - UINT32 PhysicalAddress, - UINT8 **TablePtr) -{ - - /* Allocate a buffer for the entire table */ - - *TablePtr = (void *) malloc ((size_t) TableHeader->Length); - if (!*TablePtr) - { - AcpiOsPrintf ("Could not allocate buffer for table length 0x%X\n", - (UINT32) TableHeader->Length); - return AE_NO_MEMORY; - } - - /* Get the entire table */ - - CopyExtendedToReal (*TablePtr, PhysicalAddress, TableHeader->Length); - AcpiOsPrintf ("%4.4s at %p (Phys %8.8X)\n", - TableHeader->Signature, *TablePtr, (UINT32) PhysicalAddress); - - if (AcpiGbl_DbOpt_verbose) - { - AcpiUtDumpBuffer ((char *) TableHeader, sizeof (ACPI_TABLE_HEADER), 0, 0); - } - - return (AE_OK); -} - - -ACPI_STATUS -AfGetTableFromXsdt ( - char *TableName, - UINT8 **TablePtr) -{ - UINT32 i; - UINT32 NumTables; - UINT32 PhysicalAddress; - ACPI_TABLE_HEADER ThisTable; - - - NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8; - - for (i = 0; i < NumTables; i++) - { - PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo; - CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER)); - - if (ACPI_COMPARE_NAME (TableName, ThisTable.Signature)) - { - AfGetTable (&ThisTable, PhysicalAddress, TablePtr); - return (AE_OK); - } - } - - return (AE_NOT_FOUND); -} - - -/****************************************************************************** - * - * FUNCTION: AfFindTable - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: Load the DSDT from the file pointer - * - *****************************************************************************/ - -ACPI_STATUS -AfFindTable ( - char *TableName, - UINT8 **TablePtr, - UINT32 *TableLength) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AfFindTable); - - - if (!AcpiGbl_DSDT) - { - Status = AfGetRsdt (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - AfDumpRsdt (); - - /* Get the rest of the required tables (DSDT, FADT) */ - - Status = AfGetAllTables (AcpiGbl_RsdtTableCount, NULL); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); - } - - - if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_DSDT)) - { - *TablePtr = (UINT8 *) AcpiGbl_DSDT; - *TableLength = AcpiGbl_DSDT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_FADT)) - { - *TablePtr = (UINT8 *) AcpiGbl_FADT; - *TableLength = AcpiGbl_FADT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_FACS)) - { - *TablePtr = (UINT8 *) AcpiGbl_FACS; - *TableLength = AcpiGbl_FACS->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_RSDT)) - { - *TablePtr = (UINT8 *) AcpiGbl_XSDT; - *TableLength = AcpiGbl_XSDT->Length; - } - else if (ACPI_COMPARE_NAME (TableName, ACPI_SIG_SSDT)) - { - AcpiOsPrintf ("Unsupported table signature: [%4.4s]\n", TableName); - *TablePtr = NULL; - return AE_SUPPORT; - } - else - { - Status = AfGetTableFromXsdt (TableName, TablePtr); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - *TableLength = (*((ACPI_TABLE_HEADER **)TablePtr))->Length; - } - - return AE_OK; - -ErrorExit: - - ACPI_EXCEPTION ((AE_INFO, Status, "During ACPI Table initialization"); - return (Status); -} - -#ifdef _HPET -UINT8 Hbuf[1024]; - -void -AfGetHpet (void) -{ - HPET_DESCRIPTION_TABLE *NewTable; - ACPI_TABLE_HEADER TableHeader; - ACPI_STATUS Status; - UINT16 i; - UINT32 Value; - UINT32 Value2; - - - /* Get HPET TEMP! */ - - ACPI_STRNCPY (TableHeader.Signature, "HPET", 4); - Status = AcpiOsTableOverride (&TableHeader, (ACPI_TABLE_HEADER **) &NewTable); - if (ACPI_FAILURE (Status)) - { - return; - } - - AcpiDbgLevel |= ACPI_LV_TABLES; - AcpiOsPrintf ("HPET table :\n"); - AcpiUtDumpBuffer ((char *) NewTable, NewTable->Header.Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); - - for (i = 0; i < 1024; i++) - { - Hbuf[i] = (UINT8) i; - } - - /* enable HPET */ - - CopyExtendedToReal (&Value, 0xD0, 4); - AcpiOsPrintf ("Reg 0xD0: %8.8X\n", Value); - - Value = dIn32 (0xD0); - AcpiOsPrintf ("Port 0xD0: %8.8X\n", Value); - Value |= ACPI_ENABLE_HPET; - - vOut32 (0xD0, Value); - Value2 = dIn32 (0xD0); - AcpiOsPrintf ("Port 0xD0: Wrote: %8.8X got %8.8X\n", Value, Value2); - - AcpiOsPrintf ("HPET block(at %8.8X):\n", NewTable->BaseAddress[2]); - CopyExtendedToReal (Hbuf, NewTable->BaseAddress[2], 1024); - AcpiUtDumpBuffer ((char *) Hbuf, 1024, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); -} -#endif /* _HPET */ - -#endif /* IA16 */ - diff --git a/sys/contrib/dev/acpica-unix/common/a16utils.asm b/sys/contrib/dev/acpica-unix/common/a16utils.asm index 534aad4e4b..e69de29bb2 100644 --- a/sys/contrib/dev/acpica-unix/common/a16utils.asm +++ b/sys/contrib/dev/acpica-unix/common/a16utils.asm @@ -1,915 +0,0 @@ -NAME BU_ASM -TITLE BU_ASM.ASM -- ASM support for DOS BU_LIB - -;**************************************************************************** -;* Copyright (C) Intel Corporation 1994-1999 -;* -;* All rights reserved. No part of this program or publication -;* may be reproduced, transmitted, transcribed, stored in a -;* retrieval system, or translated into any language or computer -;* language, in any form or by any means, electronic, mechanical, -;* magnetic, optical, chemical, manual, or otherwise, without -;* the prior written permission of Intel Corporation. -;**************************************************************************** -; -; To assemble with MASM61 -- ml /c a16utils.asm -; -;**************************************************************************** - -.286 -.MODEL large, c - -IFDEF MODEL_S -.MODEL small, c -ENDIF - -IFDEF MODEL_M -.MODEL medium, c -ENDIF - -IFDEF MODEL_L -.MODEL large, c -ENDIF - -IFDEF MODEL_C -.MODEL compact, c -ENDIF - -IFDEF MODEL_H -.MODEL huge, c -ENDIF - -;-------------------------------------------------------------------- - -GOREAL MACRO - LOCAL here - - mov eax, cr0 - and eax, 0fffffffeh - mov cr0, eax - jmp here -here: -ENDM - -;-------------------------------------------------------------------- - -GOPROT MACRO - LOCAL here - - xor eax, eax - xor edx, edx - - mov ax, ds - shl eax, 4 - lea edx, _gdt - add eax, edx - - mov [_gdt_ptr+2], ax - shr eax, 16 - mov [_gdt_ptr+4], ax - - lgdt FWORD PTR _gdt_ptr - mov eax, cr0 - or eax, 1 - mov cr0, eax - jmp here -here: -ENDM -;-------------------------------------------------------------------- - -.STACK -.DATA - -PUBLIC _dAPAwake, _dAPDone, _dAPFuncPtr, _wProcNumber, _bSPValid -PUBLIC _wCSegDS, _wCSegES, _wCSegSS, _wCSegSP, _wASegDS, _wASegES -PUBLIC _dAPHltJmp - - - - emsfilename DB 'EMMXXXX0',0 - - _dAPAwake DD 0 - _dAPDone DD 0 - _dAPFuncPtr DD 0 - _wProcNumber DW 0 - _bSPValid DB 0 - - _wASegDS DW 0 - _wASegES DW 0 - _wCSegDS DW 0 - _wCSegES DW 0 - _wCSegSS DW 0 - _wCSegSP DW 0 - - _block DW 0 - _gdt_ptr DW 23 - DD 0 - _gdt DD 0 ; NULL descriptor - DD 0 ; NULL descriptor - - ; 64K real mode style data segment - DD 0ffffh ; base 0, limit 0xffff - DD 00009200h ; data, CPL=0, 16-bit, 1 byte granularity, r/w - - ; 4G flat data segment - DD 0ffffh ; base 0, limit 0xfffff - DD 008f9200h ; data, CPL=0, 16-bit, 4K granularity, r/w - _old_es DW 0 - _old_ds DW 0 - _old_fs DW 0 - _old_gs DW 0 - _dAPHltJmp DD 0 ; jump to halt location - -.CODE -EXTERNDEF pascal cprint:proc - -PUBLIC ems_present -ems_present PROC C - mov ah,3dh ; open file - xor al,al ; read only operation - mov dx,offset emsfilename ; look for EMMXXXX0 - int 21h - jc emserror1 ; if carry flag set, then no EMM driver - - mov di,ax ; save file handle - mov bx,ax ; set up handle - mov ax,4400h ; get device (channel) info - int 21h - - mov ah,3eh ; close file - mov bx,di ; close the file handle up - int 21h - jc emserror1 ; if carry flag set, then no driver is present - - test dx,10000000b ; if bit 7 not set, then the channel is a file - jz emserror1 ; otherwise the channel is a device driver - - mov ax,1 ; 1 = EMS present - ret - -emserror1: - xor ax,ax ; 0 = EMS not present - ret -ems_present ENDP - -PUBLIC vm86 -vm86 PROC C - smsw ax - and ax, 1 - ret -vm86 ENDP - - -PUBLIC _set_rows -_set_rows PROC C rows:WORD - cmp rows, 25 - je set_25 - cmp rows, 50 - je set_50 - cmp rows, 132 - je set_132 - jmp invalid_input -set_25: - mov ah, 00 - mov al, 03 - int 10h - mov ax, rows - jmp end_set_rows -set_50: - mov ah, 00 - mov al, 03 - int 10h - xor bx, bx - mov ah, 11h - mov al, 12h - int 10h - mov ax, rows - jmp end_set_rows -set_132: - mov ah, 00 - mov al, 14h - int 10h - xor bx, bx - mov ah, 11h - mov al, 12h - int 10h - mov ax, rows - jmp end_set_rows -invalid_input: - xor ax, ax - jmp end_set_rows -end_set_rows: - ret -_set_rows ENDP - - -PUBLIC _cpuid_asm -_cpuid_asm PROC C hv:DWORD, regs:PTR DWORD - -check_8086: -.8086 - pushf - pop ax - mov cx, ax - and ax, 0fffh - push ax - popf - pushf - pop ax - and ax, 0f000h - cmp ax, 0f000h - mov ax, 10h - je end_cpuid - -check_80286: -.286 - or cx, 0f000h - push cx - popf - pushf - pop ax - and ax, 0f000h - mov ax, 20h - jz end_cpuid - -check_80386: -.386 - mov bx, sp - and sp, not 3 - pushfd - pop eax - mov ecx, eax - xor eax, 40000h - push eax - popfd - pushfd - pop eax - cmp ecx, eax - jne check_80486 - mov ax, 30h - mov sp, bx - jmp end_cpuid - -check_80486: -.486 - pushfd - pop ecx - mov ecx, eax - xor eax, 200000h - push eax - popfd - pushfd - pop eax - xor eax, ecx - mov ax, 40h - je end_cpuid - -check_cpuid: -.586 - mov eax, hv - cpuid - push ebx - IF @DataSize ; segment is far - les bx, regs - mov dword ptr es:[bx], eax - pop eax - mov dword ptr es:[bx + 4], eax - mov dword ptr es:[bx + 8], ecx - mov dword ptr es:[bx + 12], edx - ELSE ; segment is near - mov bx, regs - mov dword ptr [bx], eax - pop eax - mov dword ptr [bx + 4], eax - mov dword ptr [bx + 8], ecx - mov dword ptr [bx + 12], edx - ENDIF - mov ax, 5 -end_cpuid: - ret -_cpuid_asm ENDP - -.386p -;-------------------------------------------------------------------- -; Pentium Pro MSRs - from Pentium Pro Developer's Manual -; January 1996 - Appendix C -; -; MTRRs: 200h - 20Fh, 250h, 258h - 259h, 268h - 26Fh, 2FFh -;-------------------------------------------------------------------- -PUBLIC _read_msr -_read_msr PROC C dmsr:DWORD, pqmsr:PTR DWORD - pushad - mov ecx, dmsr - dw 320fh ; RDMSR - les bx, pqmsr - mov DWORD ptr es:[bx], eax - mov DWORD ptr es:[bx + 4], edx - popad - ret -_read_msr ENDP - -;-------------------------------------------------------------------- - -PUBLIC _write_msr -_write_msr PROC C dmsr:DWORD, pqmsr:PTR DWORD - pushad - les bx, pqmsr - mov eax, DWORD ptr es:[bx] - mov edx, DWORD ptr es:[bx + 4] - mov ecx, dmsr - dw 300fh ; WRMSR - popad - ret -_write_msr ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR0 - Reads CR0 CPU Register -; -; Output: dx:ax and eax - Contents of CR0 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR0 -dReadCR0 PROC C - mov eax, cr0 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR0 ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR2 - Reads CR2 CPU Register -; -; Output: dx:ax and eax - Contents of CR2 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR2 -dReadCR2 PROC C - mov eax, cr2 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR2 ENDP - -;---------------------------------------------------------------------------- -; Procedure: dReadCR3 - Reads CR3 CPU Register -; -; Output: dx:ax and eax - Contents of CR3 -; -; Registers: All registers preserved except EAX and EDX -;---------------------------------------------------------------------------- -PUBLIC dReadCR3 -dReadCR3 PROC C - mov eax, cr3 - mov edx, eax - shr edx, 16 ; upper 16 bits in dx - ret -dReadCR3 ENDP - - -.586 -;---------------------------------------------------------------------------- -; Procedure: dGetProcUpdateRev_asm - Reads PPP Update Revision via an MSR -; -; Output: dx:ax and eax - PPP Update Revision -; -; Registers: All registers preserved except EAX, ECX, and EDX -;---------------------------------------------------------------------------- -PUBLIC _dGetProcUpdateRev_asm -_dGetProcUpdateRev_asm PROC C - mov ecx, 08Bh ; model specific register to write - xor eax, eax - xor edx, edx - dw 300Fh ; WRMSR ==> load 0 to MSR at 8Bh - mov eax, 1 - cpuid - mov ecx, 08Bh ; model specific register to read - dw 320Fh ; RDMSR ==> EDX = (read) MSR 8Bh - mov eax, edx ; return EAX - shr edx, 16 ; return DX:AX - ret -_dGetProcUpdateRev_asm ENDP - -;-------------------------------------------------------------------- - -PUBLIC iInterruptFlagState -iInterruptFlagState PROC - pushf - pop ax - and ax, 200h - shr ax, 9 - ret -iInterruptFlagState ENDP - -;-------------------------------------------------------------------- - -.586P -PUBLIC vRealFsGs -vRealFsGs PROC C - - ; TBD: verify this on an AMD K6-2 266 MHz - ; Assert A20M# via system control port A (This is a - ; system dependent feature). - in al, 92h - and al, 0fdh - out 92h, al ; re-assert A20M# - - GOPROT - - mov ax, 8 - mov gs, ax - - GOREAL - - mov ax, [_old_fs] ; restore original - mov fs, ax - mov ax, [_old_gs] ; restore original - mov gs, ax - sti - ret -vRealFsGs ENDP - -;-------------------------------------------------------------------- -PUBLIC vFlatFsGs -vFlatFsGs PROC C - cli - mov ax, fs - mov [_old_fs], ax ; save original fs - mov ax, gs - mov [_old_gs], ax ; save original gs - - ; Deassert A20M# via system control port A (This is a - ; system dependent feature) - in al, 92h - or al, 2 - out 92h, al ; de-assert A20M# - - GOPROT - - mov ax, 10h - mov fs, ax - mov gs, ax - - GOREAL - - ret -vFlatFsGs ENDP - - -PUBLIC vRealEsDs -vRealEsDs PROC C - - ; TBD: verify this on an AMD K6-2 266 MHz - ; Assert A20M# via system control port A (This is a - ; system dependent feature). - in al, 92h - and al, 0fdh - out 92h, al ; re-assert A20M# - - GOPROT - - mov ax, 8 - mov gs, ax - - GOREAL - - mov ax, [_old_es] ; restore original - mov es, ax - mov ax, [_old_gs] ; restore original - mov gs, ax - sti - ret -vRealEsDs ENDP - -;-------------------------------------------------------------------- -PUBLIC vFlatEsDs -vFlatEsDs PROC C - cli - mov ax, es - mov [_old_es], ax ; save original - mov ax, gs - mov [_old_gs], ax ; save original - - ; Deassert A20M# via system control port A (This is a - ; system dependent feature) - in al, 92h - or al, 2 - out 92h, al ; de-assert A20M# - - GOPROT - - mov ax, 10h - mov es, ax - mov gs, ax - - GOREAL - - ret -vFlatEsDs ENDP - -PUBLIC print -print PROC PASCAL Seq:DWORD - - - pushad - mov eax, Seq - push eax - call cprint - popad - - ret -print ENDP - -PUBLIC DoMove -DoMove PROC - - push edx -; GOPROT - pop edx - - mov ecx, edx - shr ecx, 2 ; byte count / 4 = dword count - cmp ecx, 0 - je DoBytes - -NextDword: - xor eax, eax - lock or eax, gs:[esi] -; mov eax, gs:[esi] - - mov gs:[edi], eax - - add esi, 4 - add edi, 4 - loop NextDword - -DoBytes: - mov ecx, edx - and ecx, 3 - cmp ecx, 0 - je Exit ; no extra bytes to move - -NextByte: - mov al, byte ptr gs:[esi] - mov byte ptr gs:[edi], al - inc esi - inc edi - loop NextByte - -Exit: -; GOREAL - ret - -DoMove ENDP - .586 - - -;-------------------------------------------------------------------- - -PUBLIC _WriteApic -_WriteApic PROC C - call vFlatFsGs - xor ecx, ecx - xor edx, edx - - mov cx, [esp+6] ; high word of apic address - shl ecx, 16 - mov cx, [esp+4] ; low word of apic address - - mov dx, [esp+10] ; high word of apic command - shl edx, 16 - mov dx, [esp+8] ; low word of apic command - - mov gs:[ecx], edx - - call vRealFsGs - ret -_WriteApic ENDP - -;-------------------------------------------------------------------- - -PUBLIC _ReadApic -_ReadApic PROC C - call vFlatFsGs - xor ecx, ecx - - mov cx, [esp+6] ; low word of apic address - shl ecx, 16 - mov cx, [esp+4] ; high word of apic address - - mov eax, gs:[ecx] - - push eax ; save eax - call vRealFsGs - pop eax ; restore eax - - mov edx, eax - shr edx, 16 - ret -_ReadApic ENDP - -;-------------------------------------------------------------------- -; Since the AP shares the BSP's stack, coordination is needed to avoid -; simultaneous usage by both processors, which would cause corruption. -; -; While the AP is executing here, the BSP is executing the code -; which follows the call to vAPStartupAll() or vAPStartupOne() -; in bu_apic.c:vExecuteOnAPs(). After disabling interrupts, -; the BSP stores the sp value in _wCSegSP, sets _bSPValid to 1, -; and spins while _dAPDone != _dAPAwake. (Both are initially zero; -; the code below increments _dAPAwake before spinning on _bSPValid.) -; -; XXX - There is a race condition here: if the BSP makes it all -; XXX - the way to its spin loop on _dAPDone != _dAPAwake before -; XXX - the AP increments _dAPAwake, the BSP will exit the spin -; XXX - loop without actually having waited for the AP to finish. - -PUBLIC _vSetupAP -_vSetupAP PROC C - cli - mov ax, @data - mov ds, ax - mov esp, 0 - lock inc dword ptr [_dAPAwake] -spin1: - mov al, [_bSPValid] - cmp al, 1 - jne spin1 -; XXX - The following line is supposed to provide some validity checking, -; XXX - but it does not entirely succeed. It is possible for > 1 AP to -; XXX - see _bSPValid == 1, and exit the spin1 loop just above, before -; XXX - the first one out has had time to decrement _bSPValid; this race -; XXX - defeats the purpose of decrementing it. The decrement is likely -; XXX - not needed anyway due to the exclusion provided by the spin2 loop -; XXX - below. - lock dec byte ptr[_bSPValid] - - mov ax, [_wCSegSS] - mov ss, ax - mov sp, [_wCSegSP] - -; critical section - determining unique cpu signatures - -spin2: - mov eax, 1 -; XXX - Should the following line have a 'lock' prefix? - xchg word ptr [_block], ax - test ax, ax - jne spin2 - - mov ax, ds ; Save ASM DS and ES in global vars - mov [_wASegDS], ax - mov ax, es - mov [_wASegES], ax - - mov ax, [_wCSegES] - mov es, ax - mov ax, [_wCSegDS] ; Restore C DS and ES from global vars - mov ds, ax - -; Update Current Processor Number. Mutual exclusion from other AP's is -; guaranteed by the spin2 loop above. -; Note that the "processor number" determined here represents the order -; in which the processors happened to get through the spin2 lock, and -; has nothing to do with APIC numbers. A system having > 1 AP will not -; necessarily number the AP's consistently from one run to the next. - mov eax, [_dAPDone] - inc eax - mov [_wProcNumber], ax - - call [_dAPFuncPtr] ; _dAPFuncPtr needs to point to a void function - - mov ax, [_wASegDS] ; Restore ASM DS and ES from global vars - mov ds, ax - mov ax, [_wASegES] - mov es, ax - - lock inc dword ptr [_dAPDone] - lock inc byte ptr [_bSPValid] - - xor eax, eax -; A simple 'mov' would serve as well as the following 'xchg'. - xchg word ptr [_block], ax - wbinvd - mov si, offset _dAPHltJmp - jmp dword ptr [si] ; Jump to HLT, JMP $-1 in F000 segment - hlt ; Should never get here -_vSetupAP ENDP - -;-------------------------------------------------------------------- - -PUBLIC bIn8 -bIn8 PROC C wPort:WORD - xor ax, ax - mov dx, wPort - in al, dx - ret -bIn8 ENDP - -;-------------------------------------------------------------------- - -PUBLIC wIn16 -wIn16 PROC C wPort:WORD - mov dx, wPort - in ax, dx - ret -wIn16 ENDP - -;-------------------------------------------------------------------- - -PUBLIC dIn32 -dIn32 PROC C wPort:WORD - mov dx, wPort - in eax, dx - mov edx, eax - shr edx, 16 - ret -dIn32 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut8 -vOut8 PROC C wPort:WORD, bValue:BYTE - mov dx, wPort - mov al, bValue - out dx, al - ret -vOut8 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut16 -vOut16 PROC C wPort:WORD, wValue:WORD - mov dx, wPort - mov ax, wValue - out dx, ax - ret -vOut16 ENDP - -;-------------------------------------------------------------------- - -PUBLIC vOut32 -vOut32 PROC C wPort:WORD, dValue:DWORD - mov dx, wPort - mov eax, dValue - out dx, eax - ret -vOut32 ENDP - -;-------------------------------------------------------------------- - -; int FlatMove (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMoveX -FlatMoveX PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - - movzx ecx, sSize - cmp ecx, 0 - je SKipMemoryMove ; skip memory move if 0==sSize - - mov eax, dDest - cmp eax, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - - mov ebx, dSrc -NextByte: - mov dl, gs:[ebx][ecx - 1] - mov gs:[eax][ecx - 1], dl - loop NextByte - - call vRealFsGs - xor ax, ax -NotRealMode: - ret - -SkipMemoryMove: - mov ax, 1 ; return error code - ret -FlatMoveX ENDP - - -; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMove32 -FlatMove32 PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - movzx edx, sSize - mov esi, dSrc - mov edi, dDest - - push edx - call print - push esi - call print - push edi - call print - - cmp edx, 0 - je SkipMemoryMove ; skip memory move if 0==sSize - - cmp edi, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - call DoMove ; edx=Count, esi=src, edi=dst - - movzx ecx, sSize - shr ecx, 2 - mov edi, dDest -PrintLoop: - mov eax, gs:[edi] - push eax - call print - add edi, 4 - loop PrintLoop - - call vRealFsGs - xor ax, ax - -NotRealMode: - ret - -SkipMemoryMove: - call print - call vRealEsDs - mov ax, 1 ; return error code - ret - -FlatMove32 ENDP - - -; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize) -PUBLIC FlatMove32x -FlatMove32x PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD - call vm86 ; check if VM86 mode - cmp ax, 0 - jne NotRealMode ; skip memory move if not in real mode - - call vFlatFsGs ; set up FS and GS as 4GB limit selectors with - ; base 0:0 and de-assert A20M# - movzx ecx, sSize - cmp ecx, 0 - je SKipMemoryMove ; skip memory move if 0==sSize - - mov eax, dDest - cmp eax, 400h - jbe SkipMemoryMove ; skip memory move if destination is 40:0 - ; BIOS Data Area or less (IVT) - - mov ebx, dSrc - mov esi, 0 - - push ecx - call print - push ebx - call print - push eax - call print - - shr ecx, 2 ; byte count / 4 = dword count - cmp ecx, 0 - je DoBytes - -NextDword: - mov edx, dword ptr gs:[ebx][esi] - mov dword ptr gs:[eax][esi], edx - push edx - call print - add esi, 4 - loop NextDword - -DoBytes: - movzx ecx, sSize - and ecx, 3 - cmp ecx, 0 - je Exit ; no extra bytes to move - -NextByte: - mov dl, gs:[ebx][esi] - mov gs:[eax][esi], dl - inc esi - loop NextByte - -Exit: - call vRealFsGs - xor ax, ax - -NotRealMode: - ret - -SkipMemoryMove: - mov ax, 1 ; return error code - ret -FlatMove32x ENDP -END diff --git a/sys/contrib/dev/acpica-unix/common/adfile.c b/sys/contrib/dev/acpica-unix/common/adfile.c index 1de4b248f8..a7020cb9c2 100644 --- a/sys/contrib/dev/acpica-unix/common/adfile.c +++ b/sys/contrib/dev/acpica-unix/common/adfile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,7 +119,6 @@ #include "acapps.h" #include -#include #define _COMPONENT ACPI_TOOLS @@ -127,20 +126,21 @@ /* Local prototypes */ -INT32 +static INT32 AdWriteBuffer ( char *Filename, char *Buffer, UINT32 Length); -char FilenameBuf[20]; +static char FilenameBuf[20]; + /****************************************************************************** * * FUNCTION: AfGenerateFilename * - * PARAMETERS: Prefix - prefix string - * TableId - The table ID + * PARAMETERS: Prefix - prefix string + * TableId - The table ID * * RETURN: Pointer to the completed string * @@ -180,9 +180,9 @@ AdGenerateFilename ( * * FUNCTION: AfWriteBuffer * - * PARAMETERS: Filename - name of file - * Buffer - data to write - * Length - length of data + * PARAMETERS: Filename - name of file + * Buffer - data to write + * Length - length of data * * RETURN: Actual number of bytes written * @@ -190,7 +190,7 @@ AdGenerateFilename ( * ******************************************************************************/ -INT32 +static INT32 AdWriteBuffer ( char *Filename, char *Buffer, @@ -217,10 +217,10 @@ AdWriteBuffer ( * * FUNCTION: AfWriteTable * - * PARAMETERS: Table - pointer to the ACPI table - * Length - length of the table - * TableName - the table signature - * OemTableID - from the table header + * PARAMETERS: Table - pointer to the ACPI table + * Length - length of the table + * TableName - the table signature + * OemTableID - from the table header * * RETURN: None * @@ -272,7 +272,7 @@ FlGenerateFilename ( * Copy the original filename to a new buffer. Leave room for the worst case * where we append the suffix, an added dot and the null terminator. */ - NewFilename = ACPI_ALLOCATE_ZEROED ( + NewFilename = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); strcpy (NewFilename, InputFilename); @@ -314,7 +314,7 @@ FlStrdup ( char *NewString; - NewString = ACPI_ALLOCATE (strlen (String) + 1); + NewString = ACPI_ALLOCATE ((ACPI_SIZE) strlen (String) + 1); if (!NewString) { return (NULL); diff --git a/sys/contrib/dev/acpica-unix/common/adisasm.c b/sys/contrib/dev/acpica-unix/common/adisasm.c index 8aaa3b4bb5..748561f708 100644 --- a/sys/contrib/dev/acpica-unix/common/adisasm.c +++ b/sys/contrib/dev/acpica-unix/common/adisasm.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -132,47 +132,36 @@ #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("adisasm") -extern int AslCompilerdebug; + +extern int AslCompilerdebug; + ACPI_STATUS LsDisplayNamespace ( void); void -LsSetupNsList (void * Handle); +LsSetupNsList ( + void *Handle); /* Local prototypes */ -void +static void AdCreateTableHeader ( char *Filename, ACPI_TABLE_HEADER *Table); -void -AdDisassemblerHeader ( - char *Filename); - -void -AdAddExternalsToNamespace ( - void); - -UINT32 -AdMethodExternalCount ( - void); - -ACPI_STATUS +static ACPI_STATUS AdDeferredParse ( ACPI_PARSE_OBJECT *Op, UINT8 *Aml, UINT32 AmlLength); -ACPI_STATUS +static ACPI_STATUS AdParseDeferredOps ( ACPI_PARSE_OBJECT *Root); -ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; - /* Stubs for ASL compiler */ @@ -192,7 +181,6 @@ AcpiDsMethodError ( { return (Status); } - #endif ACPI_STATUS @@ -238,18 +226,19 @@ AcpiDsMethodDataInitArgs ( } -ACPI_TABLE_DESC LocalTables[1]; +static ACPI_TABLE_DESC LocalTables[1]; +static ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; /******************************************************************************* * * FUNCTION: AdInitialize * - * PARAMETERS: None. + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: CA initialization + * DESCRIPTION: ACPICA and local initialization * ******************************************************************************/ @@ -288,97 +277,23 @@ AdInitialize ( /* Setup the Table Manager (cheat - there is no RSDT) */ - AcpiGbl_RootTableList.Size = 1; - AcpiGbl_RootTableList.Count = 0; + AcpiGbl_RootTableList.MaxTableCount = 1; + AcpiGbl_RootTableList.CurrentTableCount = 0; AcpiGbl_RootTableList.Tables = LocalTables; return (Status); } -/******************************************************************************* - * - * FUNCTION: AdAddExternalsToNamespace - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: - * - ******************************************************************************/ - -void -AdAddExternalsToNamespace ( - void) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_EXTERNAL_LIST *External = AcpiGbl_ExternalList; - ACPI_OPERAND_OBJECT *MethodDesc; - - - while (External) - { - Status = AcpiNsLookup (NULL, External->InternalPath, External->Type, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &Node); - - if (External->Type == ACPI_TYPE_METHOD) - { - MethodDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); - MethodDesc->Method.ParamCount = (UINT8) External->Value; - Node->Object = MethodDesc; - } - - External = External->Next; - } -} - - -/******************************************************************************* - * - * FUNCTION: AdMethodExternalCount - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Return the number of externals that have been generated - * - ******************************************************************************/ - -UINT32 -AdMethodExternalCount ( - void) -{ - ACPI_EXTERNAL_LIST *External = AcpiGbl_ExternalList; - UINT32 Count = 0; - - - while (External) - { - if (External->Type == ACPI_TYPE_METHOD) - { - Count++; - } - - External = External->Next; - } - - return (Count); -} - - /****************************************************************************** * * FUNCTION: AdAmlDisassemble * - * PARAMETERS: Filename - AML input filename - * OutToFile - TRUE if output should go to a file - * Prefix - Path prefix for output - * OutFilename - where the filename is returned - * GetAllTables - TRUE if all tables are desired + * PARAMETERS: Filename - AML input filename + * OutToFile - TRUE if output should go to a file + * Prefix - Path prefix for output + * OutFilename - where the filename is returned + * GetAllTables - TRUE if all tables are desired * * RETURN: Status * @@ -386,8 +301,6 @@ AdMethodExternalCount ( * *****************************************************************************/ -extern char *Gbl_ExternalFilename; - ACPI_STATUS AdAmlDisassemble ( BOOLEAN OutToFile, @@ -399,16 +312,16 @@ AdAmlDisassemble ( ACPI_STATUS Status; char *DisasmFilename = NULL; char *ExternalFilename; + ACPI_EXTERNAL_FILE *ExternalFileList = AcpiGbl_ExternalFileList; FILE *File = NULL; ACPI_TABLE_HEADER *Table = NULL; ACPI_TABLE_HEADER *ExternalTable; ACPI_OWNER_ID OwnerId; - ACPI_EXTERNAL_LIST *NextExternal; /* - * Input: AML Code from either a file, - * or via GetTables (memory or registry) + * Input: AML code from either a file or via GetTables (memory or + * registry) */ if (Filename) { @@ -422,53 +335,55 @@ AdAmlDisassemble ( * External filenames separated by commas * Example: iasl -e file1,file2,file3 -d xxx.aml */ - if (Gbl_ExternalFilename) + while (ExternalFileList) { - ExternalFilename = strtok (Gbl_ExternalFilename, ","); + ExternalFilename = ExternalFileList->Path; + if (!ACPI_STRCMP (ExternalFilename, Filename)) + { + /* Next external file */ + + ExternalFileList = ExternalFileList->Next; + + continue; + } - while (ExternalFilename) + Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable); + if (ACPI_FAILURE (Status)) + { + return Status; + } + + /* Load external table for symbol resolution */ + + if (ExternalTable) { - Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable); + Status = AdParseTable (ExternalTable, &OwnerId, TRUE, TRUE); if (ACPI_FAILURE (Status)) { + AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", + AcpiFormatException (Status)); return Status; } - /* Load external table for symbol resolution */ - - if (ExternalTable) - { - Status = AdParseTable (ExternalTable, &OwnerId, TRUE, TRUE); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", - AcpiFormatException (Status)); - return Status; - } - - /* - * Load namespace from names created within control methods - * Set owner id of nodes in external table - */ - AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, - AcpiGbl_RootNode, OwnerId); - AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); - } + /* + * Load namespace from names created within control methods + * Set owner id of nodes in external table + */ + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + } - /* Next external file name */ + /* Next external file */ - ExternalFilename = strtok (NULL, ","); - } + ExternalFileList = ExternalFileList->Next; + } - /* Clear external list generated by Scope in external tables */ + /* Clear external list generated by Scope in external tables */ - while (AcpiGbl_ExternalList) - { - NextExternal = AcpiGbl_ExternalList->Next; - ACPI_FREE (AcpiGbl_ExternalList->Path); - ACPI_FREE (AcpiGbl_ExternalList); - AcpiGbl_ExternalList = NextExternal; - } + if (AcpiGbl_ExternalFileList) + { + AcpiDmClearExternalList (); } } else @@ -501,8 +416,7 @@ AdAmlDisassemble ( } /* - * Output: ASL code. - * Redirect to a file if requested + * Output: ASL code. Redirect to a file if requested */ if (OutToFile) { @@ -589,11 +503,11 @@ AdAmlDisassemble ( * tree with the new information (namely, the number of arguments per * method) */ - if (AdMethodExternalCount ()) + if (AcpiDmGetExternalMethodCount ()) { fprintf (stderr, - "\nFound %d external control methods, reparsing with new information\n", - AdMethodExternalCount()); + "\nFound %u external control methods, reparsing with new information\n", + AcpiDmGetExternalMethodCount ()); /* * Reparse, rebuild namespace. no need to xref namespace @@ -605,13 +519,14 @@ AdAmlDisassemble ( AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Parent = NULL; AcpiGbl_RootNodeStruct.Child = NULL; AcpiGbl_RootNodeStruct.Peer = NULL; AcpiGbl_RootNodeStruct.Object = NULL; - AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; + AcpiGbl_RootNodeStruct.Flags = 0; Status = AcpiNsRootInitialize (); - AdAddExternalsToNamespace (); + AcpiDmAddExternalsToNamespace (); /* Parse table. No need to reload it, however (FALSE) */ @@ -697,10 +612,10 @@ AdDisassemblerHeader ( /* Header and input table info */ - AcpiOsPrintf ("/*\n * Intel ACPI Component Architecture\n"); - AcpiOsPrintf (" * AML Disassembler version %8.8X\n", ACPI_CA_VERSION); + AcpiOsPrintf ("/*\n"); + AcpiOsPrintf (ACPI_COMMON_HEADER ("AML Disassembler", " * ")); - AcpiOsPrintf (" *\n * Disassembly of %s, %s", Filename, ctime (&Timer)); + AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer)); AcpiOsPrintf (" *\n"); } @@ -719,7 +634,7 @@ AdDisassemblerHeader ( * *****************************************************************************/ -void +static void AdCreateTableHeader ( char *Filename, ACPI_TABLE_HEADER *Table) @@ -733,7 +648,7 @@ AdCreateTableHeader ( */ AdDisassemblerHeader (Filename); - AcpiOsPrintf (" *\n * Original Table Header:\n"); + AcpiOsPrintf (" * Original Table Header:\n"); AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature); AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length); @@ -752,7 +667,7 @@ AdCreateTableHeader ( if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT)) { - AcpiOsPrintf (" **** ACPI 1.0, no 64-bit math support"); + AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support"); } break; @@ -778,7 +693,7 @@ AdCreateTableHeader ( AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision); AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId); AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); - AcpiOsPrintf (" */\n"); + AcpiOsPrintf (" */\n\n"); /* Create AML output filename based on input filename */ @@ -796,7 +711,7 @@ AdCreateTableHeader ( /* Open the ASL definition block */ AcpiOsPrintf ( - "DefinitionBlock (\"%s\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", 0x%8.8X)\n", + "DefinitionBlock (\"%s\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", NewFilename, Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); @@ -855,9 +770,9 @@ AdDisplayTables ( * * FUNCTION: AdDeferredParse * - * PARAMETERS: Op - Root Op of the deferred opcode - * Aml - Pointer to the raw AML - * AmlLength - Length of the AML + * PARAMETERS: Op - Root Op of the deferred opcode + * Aml - Pointer to the raw AML + * AmlLength - Length of the AML * * RETURN: Status * @@ -866,7 +781,7 @@ AdDisplayTables ( * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AdDeferredParse ( ACPI_PARSE_OBJECT *Op, UINT8 *Aml, @@ -981,7 +896,7 @@ AdDeferredParse ( * * FUNCTION: AdParseDeferredOps * - * PARAMETERS: Root - Root of the parse tree + * PARAMETERS: Root - Root of the parse tree * * RETURN: Status * @@ -989,7 +904,7 @@ AdDeferredParse ( * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AdParseDeferredOps ( ACPI_PARSE_OBJECT *Root) { @@ -1055,8 +970,8 @@ AdParseDeferredOps ( * * FUNCTION: AdGetLocalTables * - * PARAMETERS: Filename - Not used - * GetAllTables - TRUE if all tables are desired + * PARAMETERS: Filename - Not used + * GetAllTables - TRUE if all tables are desired * * RETURN: Status * @@ -1108,7 +1023,7 @@ AdGetLocalTables ( * is architecture-dependent. */ NumTables = (NewTable->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize; - AcpiOsPrintf ("There are %d tables defined in the %4.4s\n\n", + AcpiOsPrintf ("There are %u tables defined in the %4.4s\n\n", NumTables, NewTable->Signature); /* Get the FADT */ @@ -1138,6 +1053,11 @@ AdGetLocalTables ( Status = AcpiTbStoreTable (0, NewTable, NewTable->Length, 0, &TableIndex); + if (ACPI_FAILURE (Status)) + { + fprintf (stderr, "Could not store DSDT\n"); + return AE_NO_ACPI_TABLES; + } } else { @@ -1169,10 +1089,10 @@ AdGetLocalTables ( * * FUNCTION: AdParseTable * - * PARAMETERS: Table - Pointer to the raw table - * OwnerId - Returned OwnerId of the table - * LoadTable - If add table to the global table list - * External - If this is an external table + * PARAMETERS: Table - Pointer to the raw table + * OwnerId - Returned OwnerId of the table + * LoadTable - If add table to the global table list + * External - If this is an external table * * RETURN: Status * @@ -1241,7 +1161,7 @@ AdParseTable ( /* If LoadTable is FALSE, we are parsing the last loaded table */ - TableIndex = AcpiGbl_RootTableList.Count - 1; + TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; /* Pass 2 */ diff --git a/sys/contrib/dev/acpica-unix/common/adwalk.c b/sys/contrib/dev/acpica-unix/common/adwalk.c index 67d9b11389..b4e227daba 100644 --- a/sys/contrib/dev/acpica-unix/common/adwalk.c +++ b/sys/contrib/dev/acpica-unix/common/adwalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -118,7 +118,6 @@ #include "accommon.h" #include "acparser.h" #include "amlcode.h" -#include "acdebug.h" #include "acdisasm.h" #include "acdispat.h" #include "acnamesp.h" @@ -184,7 +183,7 @@ AcpiDmResourceDescendingOp ( * * FUNCTION: AcpiDmDumpTree * - * PARAMETERS: Origin - Starting object + * PARAMETERS: Origin - Starting object * * RETURN: None * @@ -218,7 +217,7 @@ AcpiDmDumpTree ( * * FUNCTION: AcpiDmFindOrphanMethods * - * PARAMETERS: Origin - Starting object + * PARAMETERS: Origin - Starting object * * RETURN: None * @@ -426,7 +425,6 @@ AcpiDmDumpDescending ( void *Context) { ACPI_OP_WALK_INFO *Info = Context; - const ACPI_OPCODE_INFO *OpInfo; char *Path; @@ -435,11 +433,9 @@ AcpiDmDumpDescending ( return (AE_OK); } - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - Info->Count++; - /* Most of the information (count, level, name) here */ + Info->Count++; AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level); AcpiDmIndent (Level); AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode)); @@ -472,7 +468,7 @@ AcpiDmDumpDescending ( case AML_METHOD_OP: case AML_DEVICE_OP: case AML_INT_NAMEDFIELD_OP: - AcpiOsPrintf ("%4.4s", &Op->Named.Name); + AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name)); break; default: @@ -536,22 +532,22 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp); - AcpiOsPrintf ("/* A-CHILDREN: %d Actual %d */\n", ArgCount, AcpiDmCountChildren (Op)); + AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", ArgCount, AcpiDmCountChildren (Op)); if (ArgCount < 1) { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; #endif @@ -567,7 +563,7 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } @@ -576,11 +572,11 @@ AcpiDmFindOrphanDescending ( { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; @@ -611,7 +607,7 @@ AcpiDmFindOrphanDescending ( /* And namepath is the first argument */ (ParentOp->Common.Value.Arg == Op)) { - AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_INTEGER, 0); break; } } @@ -621,7 +617,7 @@ AcpiDmFindOrphanDescending ( * operator) - it *must* be a method invocation, nothing else is * grammatically possible. */ - AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); } break; @@ -796,6 +792,7 @@ AcpiDmXrefDescendingOp ( ACPI_PARSE_OBJECT *NextOp; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; + UINT32 ParamCount = 0; WalkState = Info->WalkState; @@ -858,7 +855,7 @@ AcpiDmXrefDescendingOp ( { if (Status == AE_NOT_FOUND) { - AcpiDmAddToExternalList (Path, (UINT8) ObjectType, 0); + AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType, 0); /* * We could install this into the namespace, but we catch duplicate @@ -884,18 +881,13 @@ AcpiDmXrefDescendingOp ( if (Object) { ObjectType2 = Object->Common.Type; + if (ObjectType2 == ACPI_TYPE_METHOD) + { + ParamCount = Object->Method.ParamCount; + } } - if (ObjectType2 == ACPI_TYPE_METHOD) - { - AcpiDmAddToExternalList (Path, ACPI_TYPE_METHOD, - Object->Method.ParamCount); - } - else - { - AcpiDmAddToExternalList (Path, (UINT8) ObjectType2, 0); - } - + AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType2, ParamCount); Op->Common.Node = Node; } else diff --git a/sys/contrib/dev/acpica-unix/common/dmextern.c b/sys/contrib/dev/acpica-unix/common/dmextern.c new file mode 100644 index 0000000000..0c3580ff46 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/common/dmextern.c @@ -0,0 +1,743 @@ +/****************************************************************************** + * + * Module Name: dmextern - Support for External() ASL statements + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdisasm.h" + + +/* + * This module is used for application-level code (iASL disassembler) only. + * + * It contains the code to create and emit any necessary External() ASL + * statements for the module being disassembled. + */ +#define _COMPONENT ACPI_CA_DISASSEMBLER + ACPI_MODULE_NAME ("dmextern") + + +/* + * This table maps ACPI_OBJECT_TYPEs to the corresponding ASL + * ObjectTypeKeyword. Used to generate typed external declarations + */ +static const char *AcpiGbl_DmTypeNames[] = +{ + /* 00 */ "", /* Type ANY */ + /* 01 */ ", IntObj", + /* 02 */ ", StrObj", + /* 03 */ ", BuffObj", + /* 04 */ ", PkgObj", + /* 05 */ ", FieldUnitObj", + /* 06 */ ", DeviceObj", + /* 07 */ ", EventObj", + /* 08 */ ", MethodObj", + /* 09 */ ", MutexObj", + /* 10 */ ", OpRegionObj", + /* 11 */ ", PowerResObj", + /* 12 */ ", ProcessorObj", + /* 13 */ ", ThermalZoneObj", + /* 14 */ ", BuffFieldObj", + /* 15 */ ", DDBHandleObj", + /* 16 */ "", /* Debug object */ + /* 17 */ ", FieldUnitObj", + /* 18 */ ", FieldUnitObj", + /* 19 */ ", FieldUnitObj" +}; + + +/* Local prototypes */ + +static const char * +AcpiDmGetObjectTypeName ( + ACPI_OBJECT_TYPE Type); + +static char * +AcpiDmNormalizeParentPrefix ( + ACPI_PARSE_OBJECT *Op, + char *Path); + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGetObjectTypeName + * + * PARAMETERS: Type - An ACPI_OBJECT_TYPE + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Map an object type to the ASL object type string. + * + ******************************************************************************/ + +static const char * +AcpiDmGetObjectTypeName ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type == ACPI_TYPE_LOCAL_SCOPE) + { + Type = ACPI_TYPE_DEVICE; + } + + else if (Type > ACPI_TYPE_LOCAL_INDEX_FIELD) + { + return (""); + } + + return (AcpiGbl_DmTypeNames[Type]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmNormalizeParentPrefix + * + * PARAMETERS: Op - Parse op + * Path - Path with parent prefix + * + * RETURN: The full pathname to the object (from the namespace root) + * + * DESCRIPTION: Returns the full pathname of a path with parent prefix + * The caller must free the fullpath returned. + * + ******************************************************************************/ + +static char * +AcpiDmNormalizeParentPrefix ( + ACPI_PARSE_OBJECT *Op, + char *Path) +{ + ACPI_NAMESPACE_NODE *Node; + char *Fullpath; + char *ParentPath; + ACPI_SIZE Length; + + + /* Search upwards in the parse tree until we reach a namespace node */ + + while (Op) + { + if (Op->Common.Node) + { + break; + } + + Op = Op->Common.Parent; + } + + if (!Op) + { + return (NULL); + } + + /* + * Find the actual parent node for the reference: + * Remove all carat prefixes from the input path. + * There may be multiple parent prefixes (For example, ^^^M000) + */ + Node = Op->Common.Node; + while (Node && (*Path == (UINT8) AML_PARENT_PREFIX)) + { + Node = Node->Parent; + Path++; + } + + if (!Node) + { + return (NULL); + } + + /* Get the full pathname for the parent node */ + + ParentPath = AcpiNsGetExternalPathname (Node); + if (!ParentPath) + { + return (NULL); + } + + Length = (ACPI_STRLEN (ParentPath) + ACPI_STRLEN (Path) + 1); + if (ParentPath[1]) + { + /* + * If ParentPath is not just a simple '\', increment the length + * for the required dot separator (ParentPath.Path) + */ + Length++; + } + + Fullpath = ACPI_ALLOCATE_ZEROED (Length); + if (!Fullpath) + { + goto Cleanup; + } + + /* + * Concatenate parent fullpath and path. For example, + * parent fullpath "\_SB_", Path "^INIT", Fullpath "\_SB_.INIT" + * + * Copy the parent path + */ + ACPI_STRCAT (Fullpath, ParentPath); + + /* Add dot separator (don't need dot if parent fullpath is a single "\") */ + + if (ParentPath[1]) + { + ACPI_STRCAT (Fullpath, "."); + } + + /* Copy child path (carat parent prefix(es) were skipped above) */ + + ACPI_STRCAT (Fullpath, Path); + +Cleanup: + ACPI_FREE (ParentPath); + return (Fullpath); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddToExternalFileList + * + * PARAMETERS: PathList - Single path or list separated by comma + * + * RETURN: None + * + * DESCRIPTION: Add external files to global list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDmAddToExternalFileList ( + char *PathList) +{ + ACPI_EXTERNAL_FILE *ExternalFile; + char *Path; + char *TmpPath; + + + if (!PathList) + { + return (AE_OK); + } + + Path = strtok (PathList, ","); + + while (Path) + { + TmpPath = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (Path) + 1); + if (!TmpPath) + { + return (AE_NO_MEMORY); + } + + ACPI_STRCPY (TmpPath, Path); + + ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE)); + if (!ExternalFile) + { + ACPI_FREE (TmpPath); + return (AE_NO_MEMORY); + } + + ExternalFile->Path = TmpPath; + + if (AcpiGbl_ExternalFileList) + { + ExternalFile->Next = AcpiGbl_ExternalFileList; + } + + AcpiGbl_ExternalFileList = ExternalFile; + Path = strtok (NULL, ","); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmClearExternalFileList + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Clear the external file list + * + ******************************************************************************/ + +void +AcpiDmClearExternalFileList ( + void) +{ + ACPI_EXTERNAL_FILE *NextExternal; + + + while (AcpiGbl_ExternalFileList) + { + NextExternal = AcpiGbl_ExternalFileList->Next; + ACPI_FREE (AcpiGbl_ExternalFileList->Path); + ACPI_FREE (AcpiGbl_ExternalFileList); + AcpiGbl_ExternalFileList = NextExternal; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddToExternalList + * + * PARAMETERS: Op - Current parser Op + * Path - Internal (AML) path to the object + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * + * RETURN: None + * + * DESCRIPTION: Insert a new name into the global list of Externals which + * will in turn be later emitted as an External() declaration + * in the disassembled output. + * + ******************************************************************************/ + +void +AcpiDmAddToExternalList ( + ACPI_PARSE_OBJECT *Op, + char *Path, + UINT8 Type, + UINT32 Value) +{ + char *ExternalPath; + char *Fullpath = NULL; + ACPI_EXTERNAL_LIST *NewExternal; + ACPI_EXTERNAL_LIST *NextExternal; + ACPI_EXTERNAL_LIST *PrevExternal = NULL; + ACPI_STATUS Status; + + + if (!Path) + { + return; + } + + /* Externalize the ACPI path */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Get the full pathname from root if "Path" has a parent prefix */ + + if (*Path == (UINT8) AML_PARENT_PREFIX) + { + Fullpath = AcpiDmNormalizeParentPrefix (Op, ExternalPath); + if (Fullpath) + { + /* Set new external path */ + + ACPI_FREE (ExternalPath); + ExternalPath = Fullpath; + } + } + + /* Check all existing externals to ensure no duplicates */ + + NextExternal = AcpiGbl_ExternalList; + while (NextExternal) + { + if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) + { + /* Duplicate method, check that the Value (ArgCount) is the same */ + + if ((NextExternal->Type == ACPI_TYPE_METHOD) && + (NextExternal->Value != Value)) + { + ACPI_ERROR ((AE_INFO, + "Argument count mismatch for method %s %u %u", + NextExternal->Path, NextExternal->Value, Value)); + } + + /* Allow upgrade of type from ANY */ + + else if (NextExternal->Type == ACPI_TYPE_ANY) + { + NextExternal->Type = Type; + NextExternal->Value = Value; + } + + ACPI_FREE (ExternalPath); + return; + } + + NextExternal = NextExternal->Next; + } + + /* Allocate and init a new External() descriptor */ + + NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); + if (!NewExternal) + { + ACPI_FREE (ExternalPath); + return; + } + + NewExternal->Path = ExternalPath; + NewExternal->Type = Type; + NewExternal->Value = Value; + NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); + + /* Was the external path with parent prefix normalized to a fullpath? */ + + if (Fullpath == ExternalPath) + { + /* Get new internal path */ + + Status = AcpiNsInternalizeName (ExternalPath, &Path); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + ACPI_FREE (NewExternal); + return; + } + + /* Set flag to indicate External->InternalPath need to be freed */ + + NewExternal->Flags |= ACPI_IPATH_ALLOCATED; + } + + NewExternal->InternalPath = Path; + + /* Link the new descriptor into the global list, ordered by string length */ + + NextExternal = AcpiGbl_ExternalList; + while (NextExternal) + { + if (NewExternal->Length <= NextExternal->Length) + { + if (PrevExternal) + { + PrevExternal->Next = NewExternal; + } + else + { + AcpiGbl_ExternalList = NewExternal; + } + + NewExternal->Next = NextExternal; + return; + } + + PrevExternal = NextExternal; + NextExternal = NextExternal->Next; + } + + if (PrevExternal) + { + PrevExternal->Next = NewExternal; + } + else + { + AcpiGbl_ExternalList = NewExternal; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddExternalsToNamespace + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Add all externals to the namespace. Allows externals to be + * "resolved". + * + ******************************************************************************/ + +void +AcpiDmAddExternalsToNamespace ( + void) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *MethodDesc; + ACPI_EXTERNAL_LIST *External = AcpiGbl_ExternalList; + + + while (External) + { + /* Add the external name (object) into the namespace */ + + Status = AcpiNsLookup (NULL, External->InternalPath, External->Type, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "while adding external to namespace [%s]", + External->Path)); + } + else if (External->Type == ACPI_TYPE_METHOD) + { + /* For methods, we need to save the argument count */ + + MethodDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + MethodDesc->Method.ParamCount = (UINT8) External->Value; + Node->Object = MethodDesc; + } + + External = External->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGetExternalMethodCount + * + * PARAMETERS: None + * + * RETURN: The number of control method externals in the external list + * + * DESCRIPTION: Return the number of method externals that have been generated. + * If any control method externals have been found, we must + * re-parse the entire definition block with the new information + * (number of arguments for the methods.) This is limitation of + * AML, we don't know the number of arguments from the control + * method invocation itself. + * + ******************************************************************************/ + +UINT32 +AcpiDmGetExternalMethodCount ( + void) +{ + ACPI_EXTERNAL_LIST *External = AcpiGbl_ExternalList; + UINT32 Count = 0; + + + while (External) + { + if (External->Type == ACPI_TYPE_METHOD) + { + Count++; + } + + External = External->Next; + } + + return (Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmClearExternalList + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free the entire External info list + * + ******************************************************************************/ + +void +AcpiDmClearExternalList ( + void) +{ + ACPI_EXTERNAL_LIST *NextExternal; + + + while (AcpiGbl_ExternalList) + { + NextExternal = AcpiGbl_ExternalList->Next; + ACPI_FREE (AcpiGbl_ExternalList->Path); + ACPI_FREE (AcpiGbl_ExternalList); + AcpiGbl_ExternalList = NextExternal; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmEmitExternals + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit an External() ASL statement for each of the externals in + * the global external info list. + * + ******************************************************************************/ + +void +AcpiDmEmitExternals ( + void) +{ + ACPI_EXTERNAL_LIST *NextExternal; + + + if (!AcpiGbl_ExternalList) + { + return; + } + + /* + * Walk the list of externals (unresolved references) + * found during the AML parsing + */ + while (AcpiGbl_ExternalList) + { + AcpiOsPrintf (" External (%s%s", + AcpiGbl_ExternalList->Path, + AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type)); + + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (") // %u Arguments\n", + AcpiGbl_ExternalList->Value); + } + else + { + AcpiOsPrintf (")\n"); + } + + /* Free this external info block and move on to next external */ + + NextExternal = AcpiGbl_ExternalList->Next; + if (AcpiGbl_ExternalList->Flags & ACPI_IPATH_ALLOCATED) + { + ACPI_FREE (AcpiGbl_ExternalList->InternalPath); + } + + ACPI_FREE (AcpiGbl_ExternalList->Path); + ACPI_FREE (AcpiGbl_ExternalList); + AcpiGbl_ExternalList = NextExternal; + } + + AcpiOsPrintf ("\n"); +} diff --git a/sys/contrib/dev/acpica-unix/common/dmrestag.c b/sys/contrib/dev/acpica-unix/common/dmrestag.c index b461988152..827dc26684 100644 --- a/sys/contrib/dev/acpica-unix/common/dmrestag.c +++ b/sys/contrib/dev/acpica-unix/common/dmrestag.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -387,7 +387,7 @@ static ACPI_RESOURCE_TAG *AcpiGbl_ResourceTags [] = static UINT32 AcpiGbl_NextResourceId = 0; static UINT8 AcpiGbl_NextPrefix = 0; -static UINT8 AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] = +static char AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] = {'Y','Z','J','K','X'}; @@ -549,13 +549,6 @@ AcpiDmGetResourceNode ( return (Node); } - /* List is circular, this flag marks the end */ - - if (Node->Flags & ANOBJ_END_OF_PEER_LIST) - { - return (NULL); - } - Node = Node->Peer; } @@ -711,8 +704,8 @@ AcpiDmUpdateResourceName ( Name[0] = '_'; Name[1] = AcpiGbl_Prefix[AcpiGbl_NextPrefix]; - Name[2] = AcpiUtHexToAsciiChar (AcpiGbl_NextResourceId, 4); - Name[3] = AcpiUtHexToAsciiChar (AcpiGbl_NextResourceId, 0); + Name[2] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 4); + Name[3] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 0); /* Update globals for next name */ diff --git a/sys/contrib/dev/acpica-unix/common/dmtable.c b/sys/contrib/dev/acpica-unix/common/dmtable.c index 73a033891e..123c763a1c 100644 --- a/sys/contrib/dev/acpica-unix/common/dmtable.c +++ b/sys/contrib/dev/acpica-unix/common/dmtable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +117,8 @@ #include "accommon.h" #include "acdisasm.h" #include "actables.h" +#include "aslcompiler.h" +#include "dtcompiler.h" /* This module used for application-level code only */ @@ -125,19 +127,12 @@ /* Local Prototypes */ -static ACPI_DMTABLE_DATA * -AcpiDmGetTableData ( - char *Signature); - static void AcpiDmCheckAscii ( UINT8 *Target, + char *RepairedName, UINT32 Count); -UINT8 -AcpiTbGenerateChecksum ( - ACPI_TABLE_HEADER *Table); - /* These tables map a subtable type to a description string */ @@ -156,17 +151,86 @@ static const char *AcpiDmDmarSubnames[] = "Hardware Unit Definition", "Reserved Memory Region", "Root Port ATS Capability", + "Remapping Hardware Static Affinity", "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmEinjActions[] = +{ + "Begin Operation", + "Get Trigger Table", + "Set Error Type", + "Get Error Type", + "End Operation", + "Execute Operation", + "Check Busy Status", + "Get Command Status", + "Unknown Action" +}; + +static const char *AcpiDmEinjInstructions[] = +{ + "Read Register", + "Read Register Value", + "Write Register", + "Write Register Value", + "Noop", + "Unknown Instruction" +}; + +static const char *AcpiDmErstActions[] = +{ + "Begin Write Operation", + "Begin Read Operation", + "Begin Clear Operation", + "End Operation", + "Set Record Offset", + "Execute Operation", + "Check Busy Status", + "Get Command Status", + "Get Record Identifier", + "Set Record Identifier", + "Get Record Count", + "Begin Dummy Write", + "Unused/Unknown Action", + "Get Error Address Range", + "Get Error Address Length", + "Get Error Attributes", + "Unknown Action" +}; + +static const char *AcpiDmErstInstructions[] = +{ + "Read Register", + "Read Register Value", + "Write Register", + "Write Register Value", + "Noop", + "Load Var1", + "Load Var2", + "Store Var1", + "Add", + "Subtract", + "Add Value", + "Subtract Value", + "Stall", + "Stall While True", + "Skip Next If True", + "GoTo", + "Set Source Address", + "Set Destination Address", + "Move Data", + "Unknown Instruction" +}; + static const char *AcpiDmHestSubnames[] = { - "XPF Machine Check Exception", - "XPF Corrected Machine Check", - "NOT USED???", - "XPF Non-Maskable Interrupt", - "IPF Corrected Machine Check", - "IPF Corrected Platform Error", + "IA-32 Machine Check Exception", + "IA-32 Corrected Machine Check", + "IA-32 Non-Maskable Interrupt", + "Unknown SubTable Type", /* 3 - Reserved */ + "Unknown SubTable Type", /* 4 - Reserved */ + "Unknown SubTable Type", /* 5 - Reserved */ "PCI Express Root Port AER", "PCI Express AER (AER Endpoint)", "PCI Express/PCI-X Bridge AER", @@ -208,6 +272,13 @@ static const char *AcpiDmSratSubnames[] = "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmIvrsSubnames[] = +{ + "Hardware Definition Block", + "Memory Definition Block", + "Unknown SubTable Type" /* Reserved */ +}; + #define ACPI_FADT_PM_RESERVED 8 @@ -224,53 +295,76 @@ static const char *AcpiDmFadtProfiles[] = "Unknown Profile Type" }; +#define ACPI_GAS_WIDTH_RESERVED 5 + +static const char *AcpiDmGasAccessWidth[] = +{ + "Undefined/Legacy", + "Byte Access:8", + "Word Access:16", + "DWord Access:32", + "QWord Access:64", + "Unknown Width Encoding" +}; + /******************************************************************************* * * ACPI Table Data, indexed by signature. * - * Simple tables have only a TableInfo structure, complex tables have a handler. - * This table must be NULL terminated. RSDP and FACS are special-cased - * elsewhere. + * Each entry contains: Signature, Table Info, Handler, DtHandler, + * Template, Description + * + * Simple tables have only a TableInfo structure, complex tables have a + * handler. This table must be NULL terminated. RSDP and FACS are + * special-cased elsewhere. * ******************************************************************************/ -static ACPI_DMTABLE_DATA AcpiDmTableData[] = +ACPI_DMTABLE_DATA AcpiDmTableData[] = { - {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, "Alert Standard Format table"}, - {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, "Simple Boot Flag Table"}, - {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, "Boot Error Record Table"}, - {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, "Corrected Platform Error Polling table"}, - {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, "Debug Port table"}, - {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, "DMA Remapping table"}, - {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, "Embedded Controller Boot Resources Table"}, - {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, "Error Injection table"}, - {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, "Error Record Serialization Table"}, - {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"}, - {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, "Hardware Error Source Table"}, - {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"}, - {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"}, - {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"}, - {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"}, - {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"}, - {ACPI_SIG_SLIC, AcpiDmTableInfoSlic, NULL, "Software Licensing Description Table"}, - {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, "System Locality Information Table"}, - {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, "Serial Port Console Redirection table"}, - {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"}, - {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"}, - {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"}, - {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"}, - {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"}, - {NULL, NULL, NULL, NULL} + {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, DtCompileAsf, TemplateAsf, "Alert Standard Format table"}, + {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot, "Simple Boot Flag Table"}, + {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, NULL, TemplateBert, "Boot Error Record Table"}, + {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep, "Corrected Platform Error Polling table"}, + {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp, "Debug Port table"}, + {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar, "DMA Remapping table"}, + {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt, "Embedded Controller Boot Resources Table"}, + {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj, "Error Injection table"}, + {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"}, + {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table"}, + {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"}, + {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"}, + {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"}, + {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt, "Multiple APIC Description Table"}, + {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg, "Memory Mapped Configuration table"}, + {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi, "Management Controller Host Interface table"}, + {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct, "Maximum System Characteristics Table"}, + {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt, "Root System Description Table"}, + {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst, "Smart Battery Specification Table"}, + {ACPI_SIG_SLIC, AcpiDmTableInfoSlic, NULL, NULL, NULL, "Software Licensing Description Table"}, + {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit, "System Locality Information Table"}, + {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, NULL, TemplateSpcr, "Serial Port Console Redirection table"}, + {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, NULL, TemplateSpmi, "Server Platform Management Interface table"}, + {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat, "System Resource Affinity Table"}, + {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, NULL, TemplateTcpa, "Trusted Computing Platform Alliance table"}, + {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi, "UEFI Boot Optimization Table"}, + {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, NULL, TemplateWaet, "Windows ACPI Emulated Devices Table"}, + {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, DtCompileWdat, TemplateWdat, "Watchdog Action Table"}, + {ACPI_SIG_WDDT, AcpiDmTableInfoWddt, NULL, NULL, TemplateWddt, "Watchdog Description Table"}, + {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, NULL, TemplateWdrt, "Watchdog Resource Table"}, + {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, DtCompileXsdt, TemplateXsdt, "Extended System Description Table"}, + {NULL, NULL, NULL, NULL, NULL, NULL} }; /******************************************************************************* * - * FUNCTION: AcpiTbGenerateChecksum + * FUNCTION: AcpiDmGenerateChecksum * - * PARAMETERS: Table - Pointer to a valid ACPI table (with a - * standard ACPI header) + * PARAMETERS: Table - Pointer to table to be checksummed + * Length - Length of the table + * OriginalChecksum - Value of the checksum field * * RETURN: 8 bit checksum of buffer * @@ -279,19 +373,21 @@ static ACPI_DMTABLE_DATA AcpiDmTableData[] = ******************************************************************************/ UINT8 -AcpiTbGenerateChecksum ( - ACPI_TABLE_HEADER *Table) +AcpiDmGenerateChecksum ( + void *Table, + UINT32 Length, + UINT8 OriginalChecksum) { UINT8 Checksum; /* Sum the entire table as-is */ - Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length); + Checksum = AcpiTbChecksum ((UINT8 *) Table, Length); /* Subtract off the existing checksum value in the table */ - Checksum = (UINT8) (Checksum - Table->Checksum); + Checksum = (UINT8) (Checksum - OriginalChecksum); /* Compute the final checksum */ @@ -312,7 +408,7 @@ AcpiTbGenerateChecksum ( * ******************************************************************************/ -static ACPI_DMTABLE_DATA * +ACPI_DMTABLE_DATA * AcpiDmGetTableData ( char *Signature) { @@ -416,10 +512,14 @@ AcpiDmDumpDataTable ( } } - /* Always dump the raw table data */ + if (!Gbl_DoTemplates || Gbl_VerboseTemplates) + { + /* Dump the raw table data */ - AcpiOsPrintf ("\nRaw Table Data\n\n"); - AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY); + AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n", + ACPI_RAW_TABLE_DATA_HEADER, Length, Length); + AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY); + } } @@ -447,15 +547,31 @@ AcpiDmLineHeader ( char *Name) { - if (ByteLength) + if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */ { - AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ", - Offset, Offset, ByteLength, Name); + if (ByteLength) + { + AcpiOsPrintf ("[%.3d] %34s : ", + ByteLength, Name); + } + else + { + AcpiOsPrintf ("%40s : ", + Name); + } } - else + else /* Normal disassembler or verbose template */ { - AcpiOsPrintf ("%43s : ", - Name); + if (ByteLength) + { + AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ", + Offset, Offset, ByteLength, Name); + } + else + { + AcpiOsPrintf ("%43s : ", + Name); + } } } @@ -467,15 +583,31 @@ AcpiDmLineHeader2 ( UINT32 Value) { - if (ByteLength) + if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */ { - AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ", - Offset, Offset, ByteLength, Name, Value); + if (ByteLength) + { + AcpiOsPrintf ("[%.3d] %30s % 3d : ", + ByteLength, Name, Value); + } + else + { + AcpiOsPrintf ("%36s % 3d : ", + Name, Value); + } } - else + else /* Normal disassembler or verbose template */ { - AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s % 3d : ", - Offset, Offset, Name, Value); + if (ByteLength) + { + AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ", + Offset, Offset, ByteLength, Name, Value); + } + else + { + AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s % 3d : ", + Offset, Offset, Name, Value); + } } } @@ -495,6 +627,8 @@ AcpiDmLineHeader2 ( * * DESCRIPTION: Display ACPI table contents by walking the Info table. * + * Note: This function must remain in sync with DtGetFieldLength. + * ******************************************************************************/ ACPI_STATUS @@ -511,7 +645,9 @@ AcpiDmDumpTable ( UINT8 Temp8; UINT16 Temp16; ACPI_DMTABLE_DATA *TableData; + const char *Name; BOOLEAN LastOutputBlankLine = FALSE; + char RepairedName[8]; if (!Info) @@ -547,11 +683,17 @@ AcpiDmDumpTable ( case ACPI_DMT_UINT8: case ACPI_DMT_CHKSUM: case ACPI_DMT_SPACEID: + case ACPI_DMT_ACCWIDTH: + case ACPI_DMT_IVRS: case ACPI_DMT_MADT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: case ACPI_DMT_HESTNTYP: case ACPI_DMT_FADTPM: + case ACPI_DMT_EINJACT: + case ACPI_DMT_EINJINST: + case ACPI_DMT_ERSTACT: + case ACPI_DMT_ERSTINST: ByteLength = 1; break; case ACPI_DMT_UINT16: @@ -571,12 +713,17 @@ AcpiDmDumpTable ( ByteLength = 6; break; case ACPI_DMT_UINT56: + case ACPI_DMT_BUF7: ByteLength = 7; break; case ACPI_DMT_UINT64: case ACPI_DMT_NAME8: ByteLength = 8; break; + case ACPI_DMT_BUF16: + case ACPI_DMT_UUID: + ByteLength = 16; + break; case ACPI_DMT_STRING: ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1; break; @@ -677,17 +824,44 @@ AcpiDmDumpTable ( ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); break; + case ACPI_DMT_BUF7: + case ACPI_DMT_BUF16: + + /* + * Buffer: Size depends on the opcode and was set above. + * Each hex byte is separated with a space. + */ + for (Temp8 = 0; Temp8 < ByteLength; Temp8++) + { + AcpiOsPrintf ("%2.2X", Target[Temp8]); + if ((UINT32) (Temp8 + 1) < ByteLength) + { + AcpiOsPrintf (" "); + } + } + AcpiOsPrintf ("\n"); + break; + + case ACPI_DMT_UUID: + + /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */ + + (void) AuConvertUuidToString ((char *) Target, MsgBuffer); + + AcpiOsPrintf ("%s\n", MsgBuffer); + break; + case ACPI_DMT_STRING: - AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target)); + AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target)); break; /* Fixed length ASCII name fields */ case ACPI_DMT_SIG: - AcpiDmCheckAscii (Target, 4); - AcpiOsPrintf ("\"%4.4s\" ", Target); + AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiOsPrintf ("\"%.4s\" ", RepairedName); TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target)); if (TableData) { @@ -698,20 +872,20 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME4: - AcpiDmCheckAscii (Target, 4); - AcpiOsPrintf ("\"%4.4s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 4); + AcpiOsPrintf ("\"%.4s\"\n", RepairedName); break; case ACPI_DMT_NAME6: - AcpiDmCheckAscii (Target, 6); - AcpiOsPrintf ("\"%6.6s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 6); + AcpiOsPrintf ("\"%.6s\"\n", RepairedName); break; case ACPI_DMT_NAME8: - AcpiDmCheckAscii (Target, 8); - AcpiOsPrintf ("\"%8.8s\"\n", Target); + AcpiDmCheckAscii (Target, RepairedName, 8); + AcpiOsPrintf ("\"%.8s\"\n", RepairedName); break; /* Special Data Types */ @@ -721,7 +895,9 @@ AcpiDmDumpTable ( /* Checksum, display and validate */ AcpiOsPrintf ("%2.2X", *Target); - Temp8 = AcpiTbGenerateChecksum (Table); + Temp8 = AcpiDmGenerateChecksum (Table, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum); if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum) { AcpiOsPrintf ( @@ -737,13 +913,26 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target)); break; + case ACPI_DMT_ACCWIDTH: + + /* Encoded Access Width */ + + Temp8 = *Target; + if (Temp8 > ACPI_GAS_WIDTH_RESERVED) + { + Temp8 = ACPI_GAS_WIDTH_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", Temp8, AcpiDmGasAccessWidth[Temp8]); + break; + case ACPI_DMT_GAS: /* Generic Address Structure */ AcpiOsPrintf ("\n"); - AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, - CurrentOffset, Target, sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas); + AcpiDmDumpTable (TableLength, CurrentOffset, Target, + sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas); AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -774,6 +963,58 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%4.4X <%s>\n", ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); break; + case ACPI_DMT_EINJACT: + + /* EINJ Action types */ + + Temp8 = *Target; + if (Temp8 > ACPI_EINJ_ACTION_RESERVED) + { + Temp8 = ACPI_EINJ_ACTION_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmEinjActions[Temp8]); + break; + + case ACPI_DMT_EINJINST: + + /* EINJ Instruction types */ + + Temp8 = *Target; + if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED) + { + Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmEinjInstructions[Temp8]); + break; + + case ACPI_DMT_ERSTACT: + + /* ERST Action types */ + + Temp8 = *Target; + if (Temp8 > ACPI_ERST_ACTION_RESERVED) + { + Temp8 = ACPI_ERST_ACTION_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmErstActions[Temp8]); + break; + + case ACPI_DMT_ERSTINST: + + /* ERST Instruction types */ + + Temp8 = *Target; + if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED) + { + Temp8 = ACPI_ERST_INSTRUCTION_RESERVED; + } + + AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmErstInstructions[Temp8]); + break; + case ACPI_DMT_HEST: /* HEST subtable types */ @@ -790,8 +1031,8 @@ AcpiDmDumpTable ( case ACPI_DMT_HESTNTFY: AcpiOsPrintf ("\n"); - AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, - CurrentOffset, Target, sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify); + AcpiDmDumpTable (TableLength, CurrentOffset, Target, + sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify); AcpiOsPrintf ("\n"); LastOutputBlankLine = TRUE; break; @@ -809,7 +1050,6 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmHestNotifySubnames[Temp8]); break; - case ACPI_DMT_MADT: /* MADT subtable types */ @@ -849,12 +1089,37 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]); break; + case ACPI_DMT_IVRS: + + /* IVRS subtable types */ + + Temp8 = *Target; + switch (Temp8) + { + case ACPI_IVRS_TYPE_HARDWARE: + Name = AcpiDmIvrsSubnames[0]; + break; + + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + Name = AcpiDmIvrsSubnames[1]; + break; + + default: + Name = AcpiDmIvrsSubnames[2]; + break; + } + + AcpiOsPrintf ("%2.2X <%s>\n", *Target, Name); + break; + case ACPI_DMT_EXIT: return (AE_OK); default: ACPI_ERROR ((AE_INFO, - "**** Invalid table opcode [%X] ****\n", Info->Opcode)); + "**** Invalid table opcode [0x%X] ****\n", Info->Opcode)); return (AE_SUPPORT); } } @@ -888,6 +1153,7 @@ AcpiDmDumpTable ( static void AcpiDmCheckAscii ( UINT8 *Name, + char *RepairedName, UINT32 Count) { UINT32 i; @@ -895,9 +1161,15 @@ AcpiDmCheckAscii ( for (i = 0; i < Count; i++) { - if (!Name[i] || !isprint (Name[i])) + RepairedName[i] = (char) Name[i]; + + if (!Name[i]) + { + return; + } + if (!isprint (Name[i])) { - Name[i] = ' '; + RepairedName[i] = ' '; } } } diff --git a/sys/contrib/dev/acpica-unix/common/dmtbdump.c b/sys/contrib/dev/acpica-unix/common/dmtbdump.c index a0b0d965c3..3da66be543 100644 --- a/sys/contrib/dev/acpica-unix/common/dmtbdump.c +++ b/sys/contrib/dev/acpica-unix/common/dmtbdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,13 +124,20 @@ ACPI_MODULE_NAME ("dmtbdump") +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length); + + /******************************************************************************* * * FUNCTION: AcpiDmDumpRsdp * * PARAMETERS: Table - A RSDP * - * RETURN: Length of the table (there is no length field, use revision) + * RETURN: Length of the table (there is not always a length field, + * use revision or length if available (ACPI 2.0+)) * * DESCRIPTION: Format the contents of a RSDP * @@ -140,19 +147,42 @@ UINT32 AcpiDmDumpRsdp ( ACPI_TABLE_HEADER *Table) { - UINT32 Length = ACPI_RSDP_REV0_SIZE; + ACPI_TABLE_RSDP *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); + UINT32 Length = sizeof (ACPI_RSDP_COMMON); + UINT8 Checksum; /* Dump the common ACPI 1.0 portion */ AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1); - /* ACPI 2.0+ contains more data and has a Length field */ + /* Validate the first checksum */ + + Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON), + Rsdp->Checksum); + if (Checksum != Rsdp->Checksum) + { + AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n", + Checksum); + } + + /* The RSDP for ACPI 2.0+ contains more data and has a Length field */ - if (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table)->Revision > 0) + if (Rsdp->Revision > 0) { - Length = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table)->Length; + Length = Rsdp->Length; AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2); + + /* Validate the extended checksum over entire RSDP */ + + Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP), + Rsdp->ExtendedChecksum); + if (Checksum != Rsdp->ExtendedChecksum) + { + AcpiOsPrintf ( + "/* Incorrect Extended Checksum above, should be 0x%2.2X */\n", + Checksum); + } } return (Length); @@ -249,6 +279,10 @@ AcpiDmDumpXsdt ( * * DESCRIPTION: Format the contents of a FADT * + * NOTE: We cannot depend on the FADT version to indicate the actual + * contents of the FADT because of BIOS bugs. The table length + * is the only reliable indicator. + * ******************************************************************************/ void @@ -256,20 +290,21 @@ AcpiDmDumpFadt ( ACPI_TABLE_HEADER *Table) { - /* Common ACPI 1.0 portion of FADT */ + /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */ AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt1); - /* Check for ACPI 1.0B MS extensions (FADT revision 2) */ + /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */ - if (Table->Revision == 2) + if ((Table->Length > ACPI_FADT_V1_SIZE) && + (Table->Length <= ACPI_FADT_V2_SIZE)) { AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt2); } - /* Check for ACPI 2.0+ extended data (FADT revision 3+) */ + /* Check for FADT revision 3 fields and up (ACPI 2.0+ extended data) */ - else if (Table->Length >= sizeof (ACPI_TABLE_FADT)) + else if (Table->Length > ACPI_FADT_V2_SIZE) { AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt3); } @@ -277,6 +312,68 @@ AcpiDmDumpFadt ( /* Validate various fields in the FADT, including length */ AcpiTbCreateLocalFadt (Table, Table->Length); + + /* Validate FADT length against the revision */ + + AcpiDmValidateFadtLength (Table->Revision, Table->Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmValidateFadtLength + * + * PARAMETERS: Revision - FADT revision (Header->Revision) + * Length - FADT length (Header->Length + * + * RETURN: None + * + * DESCRIPTION: Check the FADT revision against the expected table length for + * that revision. Issue a warning if the length is not what was + * expected. This seems to be such a common BIOS bug that the + * FADT revision has been rendered virtually meaningless. + * + ******************************************************************************/ + +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length) +{ + UINT32 ExpectedLength; + + + switch (Revision) + { + case 0: + AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n"); + return; + + case 1: + ExpectedLength = ACPI_FADT_V1_SIZE; + break; + + case 2: + ExpectedLength = ACPI_FADT_V2_SIZE; + break; + + case 3: + case 4: + ExpectedLength = ACPI_FADT_V3_SIZE; + break; + + default: + return; + } + + if (Length == ExpectedLength) + { + return; + } + + AcpiOsPrintf ( + "\n// ACPI Warning: FADT revision %X does not match length: found %X expected %X\n", + Revision, Length, ExpectedLength); } @@ -306,6 +403,7 @@ AcpiDmDumpAsf ( UINT32 DataLength = 0; UINT32 DataOffset = 0; UINT32 i; + UINT8 Type; /* No main table, only sub-tables */ @@ -322,7 +420,11 @@ AcpiDmDumpAsf ( return; } - switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */ + /* The actual type is the lower 7 bits of Type */ + + Type = (UINT8) (SubTable->Header.Type & 0x7F); + + switch (Type) { case ACPI_ASF_TYPE_INFO: InfoTable = AcpiDmTableInfoAsf0; @@ -332,8 +434,8 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf1; DataInfoTable = AcpiDmTableInfoAsf1a; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ALERT)); - DataCount = ((ACPI_ASF_ALERT *) SubTable)->Alerts; - DataLength = ((ACPI_ASF_ALERT *) SubTable)->DataLength; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->Alerts; + DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_ALERT); break; @@ -341,8 +443,8 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf2; DataInfoTable = AcpiDmTableInfoAsf2a; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_REMOTE)); - DataCount = ((ACPI_ASF_REMOTE *) SubTable)->Controls; - DataLength = ((ACPI_ASF_REMOTE *) SubTable)->DataLength; + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->Controls; + DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_REMOTE); break; @@ -353,12 +455,12 @@ AcpiDmDumpAsf ( case ACPI_ASF_TYPE_ADDRESS: InfoTable = AcpiDmTableInfoAsf4; DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ADDRESS)); - DataLength = ((ACPI_ASF_ADDRESS *) SubTable)->Devices; + DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, SubTable)->Devices; DataOffset = Offset + sizeof (ACPI_ASF_ADDRESS); break; default: - AcpiOsPrintf ("\n**** Unknown ASF sub-table type %X\n", SubTable->Header.Type); + AcpiOsPrintf ("\n**** Unknown ASF sub-table type 0x%X\n", SubTable->Header.Type); return; } @@ -371,7 +473,7 @@ AcpiDmDumpAsf ( /* Dump variable-length extra data */ - switch (SubTable->Header.Type & 0x7F) /* Mask off top bit */ + switch (Type) { case ACPI_ASF_TYPE_ALERT: case ACPI_ASF_TYPE_CONTROL: @@ -471,7 +573,7 @@ AcpiDmDumpCpep ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoCpep0); + SubTable->Header.Length, AcpiDmTableInfoCpep0); if (ACPI_FAILURE (Status)) { return; @@ -479,8 +581,9 @@ AcpiDmDumpCpep ( /* Point to next sub-table */ - Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, SubTable->Length); + Offset += SubTable->Header.Length; + SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, + SubTable->Header.Length); } } @@ -550,8 +653,12 @@ AcpiDmDumpDmar ( InfoTable = AcpiDmTableInfoDmar2; ScopeOffset = sizeof (ACPI_DMAR_ATSR); break; + case ACPI_DMAR_HARDWARE_AFFINITY: + InfoTable = AcpiDmTableInfoDmar3; + ScopeOffset = sizeof (ACPI_DMAR_RHSA); + break; default: - AcpiOsPrintf ("\n**** Unknown DMAR sub-table type %X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown DMAR sub-table type 0x%X\n\n", SubTable->Type); return; } @@ -585,7 +692,7 @@ AcpiDmDumpDmar ( while (PathOffset < ScopeTable->Length) { AcpiDmLineHeader ((PathOffset + ScopeOffset + Offset), 2, "PCI Path"); - AcpiOsPrintf ("[%2.2X, %2.2X]\n", PciPath[0], PciPath[1]); + AcpiOsPrintf ("%2.2X,%2.2X\n", PciPath[0], PciPath[1]); /* Point to next PCI Path entry */ @@ -699,7 +806,7 @@ AcpiDmDumpErst ( { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); + sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0); if (ACPI_FAILURE (Status)) { return; @@ -737,6 +844,8 @@ AcpiDmDumpHest ( UINT32 Offset = sizeof (ACPI_TABLE_HEST); ACPI_DMTABLE_INFO *InfoTable; UINT32 SubTableLength; + UINT32 BankCount; + ACPI_HEST_IA_ERROR_BANK *BankTable; /* Main table */ @@ -752,31 +861,26 @@ AcpiDmDumpHest ( SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset); while (Offset < Table->Length) { + BankCount = 0; switch (SubTable->Type) { - case ACPI_HEST_TYPE_XPF_MACHINE_CHECK: + case ACPI_HEST_TYPE_IA32_CHECK: InfoTable = AcpiDmTableInfoHest0; - SubTableLength = sizeof (ACPI_HEST_XPF_MACHINE_CHECK); + SubTableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK); + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, + SubTable))->NumHardwareBanks; break; - case ACPI_HEST_TYPE_XPF_CORRECTED_MACHINE_CHECK: + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: InfoTable = AcpiDmTableInfoHest1; - SubTableLength = sizeof (ACPI_HEST_XPF_CORRECTED); + SubTableLength = sizeof (ACPI_HEST_IA_CORRECTED); + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, + SubTable))->NumHardwareBanks; break; - case ACPI_HEST_TYPE_XPF_NON_MASKABLE_INTERRUPT: - InfoTable = AcpiDmTableInfoHest3; - SubTableLength = sizeof (ACPI_HEST_XPF_NMI); - break; - - case ACPI_HEST_TYPE_IPF_CORRECTED_MACHINE_CHECK: - InfoTable = AcpiDmTableInfoHest4; - SubTableLength = sizeof (ACPI_HEST_IPF_CORRECTED); - break; - - case ACPI_HEST_TYPE_IPF_CORRECTED_PLATFORM_ERROR: - InfoTable = AcpiDmTableInfoHest5; - SubTableLength = sizeof (ACPI_HEST_IPF_CORRECTED_PLATFORM); + case ACPI_HEST_TYPE_IA32_NMI: + InfoTable = AcpiDmTableInfoHest2; + SubTableLength = sizeof (ACPI_HEST_IA_NMI); break; case ACPI_HEST_TYPE_AER_ROOT_PORT: @@ -794,7 +898,7 @@ AcpiDmDumpHest ( SubTableLength = sizeof (ACPI_HEST_AER_BRIDGE); break; - case ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE: + case ACPI_HEST_TYPE_GENERIC_ERROR: InfoTable = AcpiDmTableInfoHest9; SubTableLength = sizeof (ACPI_HEST_GENERIC); break; @@ -802,7 +906,7 @@ AcpiDmDumpHest ( default: /* Cannot continue on unknown type - no length */ - AcpiOsPrintf ("\n**** Unknown HEST sub-table type %X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown HEST sub-table type 0x%X\n", SubTable->Type); return; } @@ -814,14 +918,212 @@ AcpiDmDumpHest ( return; } - /* Point to next sub-table (each subtable is of fixed length) */ + /* Point to end of current subtable (each subtable above is of fixed length) */ Offset += SubTableLength; + + /* If there are any (fixed-length) Error Banks from above, dump them now */ + + if (BankCount) + { + BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, SubTable, SubTableLength); + SubTableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK); + + while (BankCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, BankTable, + sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank); + if (ACPI_FAILURE (Status)) + { + return; + } + Offset += sizeof (ACPI_HEST_IA_ERROR_BANK); + BankTable++; + BankCount--; + } + } + + /* Point to next sub-table */ + SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, SubTable, SubTableLength); } } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpIvrs + * + * PARAMETERS: Table - A IVRS table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a IVRS + * + ******************************************************************************/ + +static UINT8 EntrySizes[] = {4,8,16,32}; + +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_IVRS); + UINT32 EntryOffset; + UINT32 EntryLength; + UINT32 EntryType; + ACPI_IVRS_DE_HEADER *DeviceEntry; + ACPI_IVRS_HEADER *SubTable; + ACPI_DMTABLE_INFO *InfoTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIvrs); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoIvrsHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + switch (SubTable->Type) + { + case ACPI_IVRS_TYPE_HARDWARE: + InfoTable = AcpiDmTableInfoIvrs0; + break; + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + InfoTable = AcpiDmTableInfoIvrs1; + break; + default: + AcpiOsPrintf ("\n**** Unknown IVRS sub-table type 0x%X\n", + SubTable->Type); + + /* Attempt to continue */ + + if (!SubTable->Length) + { + AcpiOsPrintf ("Invalid zero length subtable\n"); + return; + } + goto NextSubTable; + } + + /* Dump the subtable */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* The hardware subtable can contain multiple device entries */ + + if (SubTable->Type == ACPI_IVRS_TYPE_HARDWARE) + { + EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE); + DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, SubTable, + sizeof (ACPI_IVRS_HARDWARE)); + + while (EntryOffset < (Offset + SubTable->Length)) + { + AcpiOsPrintf ("\n"); + /* + * Upper 2 bits of Type encode the length of the device entry + * + * 00 = 4 byte + * 01 = 8 byte + * 10 = 16 byte - currently no entries defined + * 11 = 32 byte - currently no entries defined + */ + EntryType = DeviceEntry->Type; + EntryLength = EntrySizes [EntryType >> 6]; + + switch (EntryType) + { + /* 4-byte device entries */ + + case ACPI_IVRS_TYPE_PAD4: + case ACPI_IVRS_TYPE_ALL: + case ACPI_IVRS_TYPE_SELECT: + case ACPI_IVRS_TYPE_START: + case ACPI_IVRS_TYPE_END: + + InfoTable = AcpiDmTableInfoIvrs4; + break; + + /* 8-byte entries, type A */ + + case ACPI_IVRS_TYPE_ALIAS_SELECT: + case ACPI_IVRS_TYPE_ALIAS_START: + + InfoTable = AcpiDmTableInfoIvrs8a; + break; + + /* 8-byte entries, type B */ + + case ACPI_IVRS_TYPE_PAD8: + case ACPI_IVRS_TYPE_EXT_SELECT: + case ACPI_IVRS_TYPE_EXT_START: + + InfoTable = AcpiDmTableInfoIvrs8b; + break; + + /* 8-byte entries, type C */ + + case ACPI_IVRS_TYPE_SPECIAL: + + InfoTable = AcpiDmTableInfoIvrs8c; + break; + + default: + InfoTable = AcpiDmTableInfoIvrs4; + AcpiOsPrintf ( + "\n**** Unknown IVRS device entry type/length: " + "0x%.2X/0x%X at offset 0x%.4X: (header below)\n", + EntryType, EntryLength, EntryOffset); + break; + } + + /* Dump the Device Entry */ + + Status = AcpiDmDumpTable (Table->Length, EntryOffset, + DeviceEntry, EntryLength, InfoTable); + + EntryOffset += EntryLength; + DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, DeviceEntry, + EntryLength); + } + } + +NextSubTable: + /* Point to next sub-table */ + + Offset += SubTable->Length; + SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, SubTable, SubTable->Length); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpMadt @@ -905,7 +1207,7 @@ AcpiDmDumpMadt ( InfoTable = AcpiDmTableInfoMadt10; break; default: - AcpiOsPrintf ("\n**** Unknown MADT sub-table type %X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown MADT sub-table type 0x%X\n\n", SubTable->Type); /* Attempt to continue */ @@ -969,7 +1271,7 @@ AcpiDmDumpMcfg ( { if (Offset + sizeof (ACPI_MCFG_ALLOCATION) > Table->Length) { - AcpiOsPrintf ("Warning: there are %d invalid trailing bytes\n", + AcpiOsPrintf ("Warning: there are %u invalid trailing bytes\n", sizeof (ACPI_MCFG_ALLOCATION) - (Offset - Table->Length)); return; } @@ -991,6 +1293,58 @@ AcpiDmDumpMcfg ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpMsct + * + * PARAMETERS: Table - A MSCT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a MSCT + * + ******************************************************************************/ + +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_MSCT); + ACPI_MSCT_PROXIMITY *SubTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMsct); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + sizeof (ACPI_MSCT_PROXIMITY), AcpiDmTableInfoMsct0); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to next sub-table */ + + Offset += sizeof (ACPI_MSCT_PROXIMITY); + SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, SubTable, sizeof (ACPI_MSCT_PROXIMITY)); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpSlit @@ -1044,15 +1398,20 @@ AcpiDmDumpSlit ( return; } - AcpiOsPrintf ("%2.2X ", Row[j]); + AcpiOsPrintf ("%2.2X", Row[j]); Offset++; /* Display up to 16 bytes per output row */ - if (j && (((j+1) % 16) == 0) && ((j+1) < Localities)) + if ((j+1) < Localities) { - AcpiOsPrintf ("\n"); - AcpiDmLineHeader (Offset, 0, ""); + AcpiOsPrintf (","); + + if (j && (((j+1) % 16) == 0)) + { + AcpiOsPrintf ("\n"); + AcpiDmLineHeader (Offset, 0, ""); + } } } @@ -1121,7 +1480,7 @@ AcpiDmDumpSrat ( InfoTable = AcpiDmTableInfoSrat2; break; default: - AcpiOsPrintf ("\n**** Unknown SRAT sub-table type %X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown SRAT sub-table type 0x%X\n", SubTable->Type); /* Attempt to continue */ @@ -1149,3 +1508,54 @@ NextSubTable: } } + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpWdat + * + * PARAMETERS: Table - A WDAT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a WDAT + * + ******************************************************************************/ + +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_WDAT); + ACPI_WDAT_ENTRY *SubTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, + sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to next sub-table */ + + Offset += sizeof (ACPI_WDAT_ENTRY); + SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, sizeof (ACPI_WDAT_ENTRY)); + } +} diff --git a/sys/contrib/dev/acpica-unix/common/dmtbinfo.c b/sys/contrib/dev/acpica-unix/common/dmtbinfo.c index 3574a2a711..51c31a94f7 100644 --- a/sys/contrib/dev/acpica-unix/common/dmtbinfo.c +++ b/sys/contrib/dev/acpica-unix/common/dmtbinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -139,14 +139,21 @@ #define ACPI_ERST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_ERST,f) #define ACPI_HEST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_HEST,f) #define ACPI_HPET_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_HPET,f) +#define ACPI_IVRS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_IVRS,f) #define ACPI_MADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MADT,f) #define ACPI_MCFG_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MCFG,f) +#define ACPI_MCHI_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MCHI,f) +#define ACPI_MSCT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_MSCT,f) #define ACPI_SBST_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SBST,f) #define ACPI_SLIT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SLIT,f) #define ACPI_SPCR_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SPCR,f) #define ACPI_SPMI_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SPMI,f) #define ACPI_SRAT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_SRAT,f) #define ACPI_TCPA_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_TCPA,f) +#define ACPI_UEFI_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_UEFI,f) +#define ACPI_WAET_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WAET,f) +#define ACPI_WDAT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WDAT,f) +#define ACPI_WDDT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WDDT,f) #define ACPI_WDRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_WDRT,f) /* Subtables */ @@ -163,17 +170,25 @@ #define ACPI_DMAR0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_HARDWARE_UNIT,f) #define ACPI_DMAR1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_RESERVED_MEMORY,f) #define ACPI_DMAR2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_ATSR,f) +#define ACPI_DMAR3_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_DMAR_RHSA,f) #define ACPI_EINJ0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_WHEA_HEADER,f) -#define ACPI_HEST0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_XPF_MACHINE_CHECK,f) -#define ACPI_HEST1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_XPF_CORRECTED,f) -#define ACPI_HEST3_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_XPF_NMI,f) -#define ACPI_HEST4_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IPF_CORRECTED,f) -#define ACPI_HEST5_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IPF_CORRECTED_PLATFORM,f) +#define ACPI_ERST0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_WHEA_HEADER,f) +#define ACPI_HEST0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f) +#define ACPI_HEST1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_CORRECTED,f) +#define ACPI_HEST2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_NMI,f) #define ACPI_HEST6_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER_ROOT,f) #define ACPI_HEST7_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER,f) #define ACPI_HEST8_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_AER_BRIDGE,f) #define ACPI_HEST9_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_GENERIC,f) #define ACPI_HESTN_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_NOTIFY,f) +#define ACPI_HESTB_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_HEST_IA_ERROR_BANK,f) +#define ACPI_IVRSH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_HEADER,f) +#define ACPI_IVRS0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_HARDWARE,f) +#define ACPI_IVRS1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_MEMORY,f) +#define ACPI_IVRSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DE_HEADER,f) +#define ACPI_IVRS8A_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8A,f) +#define ACPI_IVRS8B_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8B,f) +#define ACPI_IVRS8C_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_IVRS_DEVICE8C,f) #define ACPI_MADT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_APIC,f) #define ACPI_MADT1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_IO_APIC,f) #define ACPI_MADT2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f) @@ -187,10 +202,12 @@ #define ACPI_MADT10_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f) #define ACPI_MADTH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_MCFG0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f) +#define ACPI_MSCT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f) #define ACPI_SRATH_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_SRAT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_CPU_AFFINITY,f) #define ACPI_SRAT1_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_MEM_AFFINITY,f) #define ACPI_SRAT2_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f) +#define ACPI_WDAT0_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_WDAT_ENTRY,f) /* * Simplify access to flag fields by breaking them up into bytes @@ -214,6 +231,17 @@ #define ACPI_MADT8_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_INTERRUPT_SOURCE,f,o) #define ACPI_MADT9_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC,f,o) #define ACPI_MADT10_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f,o) +#define ACPI_WDDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_WDDT,f,o) +#define ACPI_EINJ0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) +#define ACPI_ERST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) +#define ACPI_HEST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f,o) +#define ACPI_HEST1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_HEST_IA_CORRECTED,f,o) +#define ACPI_HEST6_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_HEST_AER_ROOT,f,o) + +/* + * Required terminator for all tables below + */ +#define ACPI_DMT_TERMINATOR {ACPI_DMT_EXIT, 0, NULL, 0} /* @@ -230,16 +258,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[] = { - {ACPI_DMT_SIG, ACPI_HDR_OFFSET (Signature[0]), "Signature"}, - {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (Length), "Table Length"}, - {ACPI_DMT_UINT8, ACPI_HDR_OFFSET (Revision), "Revision"}, - {ACPI_DMT_CHKSUM, ACPI_HDR_OFFSET (Checksum), "Checksum"}, - {ACPI_DMT_NAME6, ACPI_HDR_OFFSET (OemId[0]), "Oem ID"}, - {ACPI_DMT_NAME8, ACPI_HDR_OFFSET (OemTableId[0]), "Oem Table ID"}, - {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (OemRevision), "Oem Revision"}, - {ACPI_DMT_NAME4, ACPI_HDR_OFFSET (AslCompilerId[0]), "Asl Compiler ID"}, - {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (AslCompilerRevision), "Asl Compiler Revision"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_SIG, ACPI_HDR_OFFSET (Signature[0]), "Signature", 0}, + {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (Length), "Table Length", DT_LENGTH}, + {ACPI_DMT_UINT8, ACPI_HDR_OFFSET (Revision), "Revision", 0}, + {ACPI_DMT_CHKSUM, ACPI_HDR_OFFSET (Checksum), "Checksum", 0}, + {ACPI_DMT_NAME6, ACPI_HDR_OFFSET (OemId[0]), "Oem ID", 0}, + {ACPI_DMT_NAME8, ACPI_HDR_OFFSET (OemTableId[0]), "Oem Table ID", 0}, + {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (OemRevision), "Oem Revision", 0}, + {ACPI_DMT_NAME4, ACPI_HDR_OFFSET (AslCompilerId[0]), "Asl Compiler ID", 0}, + {ACPI_DMT_UINT32, ACPI_HDR_OFFSET (AslCompilerRevision), "Asl Compiler Revision", 0}, + ACPI_DMT_TERMINATOR }; @@ -251,12 +279,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[] = ACPI_DMTABLE_INFO AcpiDmTableInfoGas[] = { - {ACPI_DMT_SPACEID, ACPI_GAS_OFFSET (SpaceId), "Space ID"}, - {ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitWidth), "Bit Width"}, - {ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitOffset), "Bit Offset"}, - {ACPI_DMT_UINT8, ACPI_GAS_OFFSET (AccessWidth), "Access Width"}, - {ACPI_DMT_UINT64, ACPI_GAS_OFFSET (Address), "Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_SPACEID, ACPI_GAS_OFFSET (SpaceId), "Space ID", 0}, + {ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitWidth), "Bit Width", 0}, + {ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitOffset), "Bit Offset", 0}, + {ACPI_DMT_ACCWIDTH, ACPI_GAS_OFFSET (AccessWidth), "Encoded Access Width", 0}, + {ACPI_DMT_UINT64, ACPI_GAS_OFFSET (Address), "Address", 0}, + ACPI_DMT_TERMINATOR }; @@ -268,23 +296,23 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoGas[] = ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[] = { - {ACPI_DMT_NAME8, ACPI_RSDP_OFFSET (Signature[0]), "Signature"}, - {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Checksum), "Checksum"}, - {ACPI_DMT_NAME6, ACPI_RSDP_OFFSET (OemId[0]), "Oem ID"}, - {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Revision), "Revision"}, - {ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (RsdtPhysicalAddress), "RSDT Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_NAME8, ACPI_RSDP_OFFSET (Signature[0]), "Signature", 0}, + {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Checksum), "Checksum", 0}, + {ACPI_DMT_NAME6, ACPI_RSDP_OFFSET (OemId[0]), "Oem ID", 0}, + {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Revision), "Revision", 0}, + {ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (RsdtPhysicalAddress), "RSDT Address", 0}, + ACPI_DMT_TERMINATOR }; /* ACPI 2.0+ Extensions */ ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[] = { - {ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (Length), "Length"}, - {ACPI_DMT_UINT64, ACPI_RSDP_OFFSET (XsdtPhysicalAddress), "XSDT Address"}, - {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (ExtendedChecksum), "Extended Checksum"}, - {ACPI_DMT_UINT24, ACPI_RSDP_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT64, ACPI_RSDP_OFFSET (XsdtPhysicalAddress), "XSDT Address", 0}, + {ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (ExtendedChecksum), "Extended Checksum", 0}, + {ACPI_DMT_UINT24, ACPI_RSDP_OFFSET (Reserved[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; @@ -296,16 +324,20 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = { - {ACPI_DMT_NAME4, ACPI_FACS_OFFSET (Signature[0]), "Signature"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Length), "Length"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (HardwareSignature), "Hardware Signature"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (FirmwareWakingVector), "Firmware Waking Vector(32)"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (GlobalLock), "Global Lock"}, - {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (Flags,0), "S4BIOS Support Present"}, - {ACPI_DMT_UINT64, ACPI_FACS_OFFSET (XFirmwareWakingVector), "Firmware Waking Vector(64)"}, - {ACPI_DMT_UINT8, ACPI_FACS_OFFSET (Version), "Version"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_NAME4, ACPI_FACS_OFFSET (Signature[0]), "Signature", 0}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (HardwareSignature), "Hardware Signature", 0}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (FirmwareWakingVector), "32 Firmware Waking Vector", 0}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (GlobalLock), "Global Lock", 0}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (Flags,0), "S4BIOS Support Present", 0}, + {ACPI_DMT_FLAG1, ACPI_FACS_FLAG_OFFSET (Flags,0), "64-bit Wake Supported (V2)", 0}, + {ACPI_DMT_UINT64, ACPI_FACS_OFFSET (XFirmwareWakingVector), "64 Firmware Waking Vector", 0}, + {ACPI_DMT_UINT8, ACPI_FACS_OFFSET (Version), "Version", 0}, + {ACPI_DMT_UINT24, ACPI_FACS_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_FACS_OFFSET (OspmFlags), "OspmFlags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (OspmFlags,0), "64-bit Wake Env Required (V2)", 0}, + ACPI_DMT_TERMINATOR }; @@ -319,113 +351,113 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = { - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Facs), "FACS Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Dsdt), "DSDT Address"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Model), "Model"}, - {ACPI_DMT_FADTPM, ACPI_FADT_OFFSET (PreferredProfile), "PM Profile"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (SciInterrupt), "SCI Interrupt"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (SmiCommand), "SMI Command Port"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiEnable), "ACPI Enable Value"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiDisable), "ACPI Disable Value"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (S4BiosRequest), "S4BIOS Command"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PstateControl), "P-State Control"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aEventBlock), "PM1A Event Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bEventBlock), "PM1B Event Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aControlBlock), "PM1A Control Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bControlBlock), "PM1B Control Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm2ControlBlock), "PM2 Control Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (PmTimerBlock), "PM Timer Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe0Block), "GPE0 Block Address"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe1Block), "GPE1 Block Address"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1EventLength), "PM1 Event Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1ControlLength), "PM1 Control Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm2ControlLength), "PM2 Control Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PmTimerLength), "PM Timer Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe0BlockLength), "GPE0 Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1BlockLength), "GPE1 Block Length"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1Base), "GPE1 Base Offset"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (CstControl), "_CST Support"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C2Latency), "C2 Latency"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C3Latency), "C3 Latency"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushSize), "CPU Cache Size"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushStride), "Cache Flush Stride"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyOffset), "Duty Cycle Offset"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyWidth), "Duty Cycle Width"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DayAlarm), "RTC Day Alarm Index"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MonthAlarm), "RTC Month Alarm Index"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Century), "RTC Century Index"}, - {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (BootFlags), "Boot Flags (decoded below)"}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Facs), "FACS Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Dsdt), "DSDT Address", DT_NON_ZERO}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Model), "Model", 0}, + {ACPI_DMT_FADTPM, ACPI_FADT_OFFSET (PreferredProfile), "PM Profile", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (SciInterrupt), "SCI Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (SmiCommand), "SMI Command Port", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiEnable), "ACPI Enable Value", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiDisable), "ACPI Disable Value", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (S4BiosRequest), "S4BIOS Command", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PstateControl), "P-State Control", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aEventBlock), "PM1A Event Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bEventBlock), "PM1B Event Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aControlBlock), "PM1A Control Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bControlBlock), "PM1B Control Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm2ControlBlock), "PM2 Control Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (PmTimerBlock), "PM Timer Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe0Block), "GPE0 Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe1Block), "GPE1 Block Address", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1EventLength), "PM1 Event Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1ControlLength), "PM1 Control Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm2ControlLength), "PM2 Control Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PmTimerLength), "PM Timer Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe0BlockLength), "GPE0 Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1BlockLength), "GPE1 Block Length", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1Base), "GPE1 Base Offset", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (CstControl), "_CST Support", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C2Latency), "C2 Latency", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C3Latency), "C3 Latency", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushSize), "CPU Cache Size", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushStride), "Cache Flush Stride", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyOffset), "Duty Cycle Offset", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyWidth), "Duty Cycle Width", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DayAlarm), "RTC Day Alarm Index", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MonthAlarm), "RTC Month Alarm Index", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Century), "RTC Century Index", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (BootFlags), "Boot Flags (decoded below)", DT_FLAG}, /* Boot Architecture Flags byte 0 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "Legacy Devices Supported (V2)"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "8042 Present on ports 60/64 (V2)"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "VGA Not Present (V4)"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "MSI Not Supported (V4)"}, - {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "PCIe ASPM Not Supported (V4)"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "Legacy Devices Supported (V2)", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "8042 Present on ports 60/64 (V2)", 0}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "VGA Not Present (V4)", 0}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "MSI Not Supported (V4)", 0}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "PCIe ASPM Not Supported (V4)", 0}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Flags), "Flags (decoded below)"}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, /* Flags byte 0 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD instruction is operational (V1)"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD flushes all caches (V1)"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,0), "All CPUs support C1 (V1)"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,0), "C2 works on MP system (V1)"}, - {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Power Button (V1)"}, - {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Sleep Button (V1)"}, - {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wake not in fixed reg space (V1)"}, - {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC can wake system from S4 (V1)"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD instruction is operational (V1)", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD flushes all caches (V1)", 0}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,0), "All CPUs support C1 (V1)", 0}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,0), "C2 works on MP system (V1)", 0}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Power Button (V1)", 0}, + {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Sleep Button (V1)", 0}, + {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wake not in fixed reg space (V1)", 0}, + {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC can wake system from S4 (V1)", 0}, /* Flags byte 1 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,1), "32-bit PM Timer (V1)"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,1), "Docking Supported (V1)"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,1), "Reset Register Supported (V2)"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,1), "Sealed Case (V3)"}, - {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,1), "Headless - No Video (V3)"}, - {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use native instr after SLP_TYPx (V3)"}, - {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,1), "PCIEXP_WAK Bits Supported (V4)"}, - {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use Platform Timer (V4)"}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,1), "32-bit PM Timer (V1)", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,1), "Docking Supported (V1)", 0}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,1), "Reset Register Supported (V2)", 0}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,1), "Sealed Case (V3)", 0}, + {ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,1), "Headless - No Video (V3)", 0}, + {ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use native instr after SLP_TYPx (V3)", 0}, + {ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,1), "PCIEXP_WAK Bits Supported (V4)", 0}, + {ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use Platform Timer (V4)", 0}, /* Flags byte 2 */ - {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,2), "RTC_STS valid on S4 wake (V4)"}, - {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,2), "Remote Power-on capable (V4)"}, - {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Cluster Model (V4)"}, - {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Physical Destination Mode (V4)"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,2), "RTC_STS valid on S4 wake (V4)", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,2), "Remote Power-on capable (V4)", 0}, + {ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Cluster Model (V4)", 0}, + {ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Physical Destination Mode (V4)", 0}, + ACPI_DMT_TERMINATOR }; /* ACPI 1.0 MS Extensions (FADT version 2) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = { - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset"}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, + {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; /* ACPI 2.0+ Extensions (FADT version 3+) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register"}, - {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset"}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved"}, - {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address"}, - {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bEventBlock), "PM1B Event Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aControlBlock), "PM1A Control Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bControlBlock), "PM1B Control Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm2ControlBlock), "PM2 Control Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPmTimerBlock), "PM Timer Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe0Block), "GPE0 Block"}, - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe1Block), "GPE1 Block"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, + {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address", 0}, + {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bEventBlock), "PM1B Event Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aControlBlock), "PM1A Control Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bControlBlock), "PM1B Control Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm2ControlBlock), "PM2 Control Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPmTimerBlock), "PM Timer Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe0Block), "GPE0 Block", 0}, + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe1Block), "GPE1 Block", 0}, + ACPI_DMT_TERMINATOR }; @@ -443,97 +475,97 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[] = { - {ACPI_DMT_ASF, ACPI_ASF0_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (Header.Reserved), "Reserved"}, - {ACPI_DMT_UINT16, ACPI_ASF0_OFFSET (Header.Length), "Length"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_ASF, ACPI_ASF0_OFFSET (Header.Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (Header.Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_ASF0_OFFSET (Header.Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR }; /* 0: ASF Information */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[] = { - {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinResetValue), "Minimum Reset Value"}, - {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinResetValue), "Minimum Polling Interval"}, - {ACPI_DMT_UINT16, ACPI_ASF0_OFFSET (SystemId), "System ID"}, - {ACPI_DMT_UINT32, ACPI_ASF0_OFFSET (SystemId), "Manufacturer ID"}, - {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT24, ACPI_ASF0_OFFSET (Reserved2[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinResetValue), "Minimum Reset Value", 0}, + {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (MinPollInterval), "Minimum Polling Interval", 0}, + {ACPI_DMT_UINT16, ACPI_ASF0_OFFSET (SystemId), "System ID", 0}, + {ACPI_DMT_UINT32, ACPI_ASF0_OFFSET (MfgId), "Manufacturer ID", 0}, + {ACPI_DMT_UINT8, ACPI_ASF0_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT24, ACPI_ASF0_OFFSET (Reserved2[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; /* 1: ASF Alerts */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1[] = { - {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (AssertMask), "AssertMask"}, - {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (DeassertMask), "DeassertMask"}, - {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (Alerts), "Alert Count"}, - {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (DataLength), "Alert Data Length"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (AssertMask), "AssertMask", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (DeassertMask), "DeassertMask", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (Alerts), "Alert Count", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1_OFFSET (DataLength), "Alert Data Length", 0}, + ACPI_DMT_TERMINATOR }; /* 1a: ASF Alert data */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1a[] = { - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Address), "Address"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Command), "Command"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Mask), "Mask"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Value), "Value"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SensorType), "SensorType"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Type), "Type"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Offset), "Offset"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SourceType), "SourceType"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Severity), "Severity"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SensorNumber), "SensorNumber"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Entity), "Entity"}, - {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Instance), "Instance"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Address), "Address", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Command), "Command", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Mask), "Mask", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Value), "Value", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SensorType), "SensorType", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Type), "Type", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Offset), "Offset", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SourceType), "SourceType", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Severity), "Severity", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (SensorNumber), "SensorNumber", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Entity), "Entity", 0}, + {ACPI_DMT_UINT8, ACPI_ASF1a_OFFSET (Instance), "Instance", 0}, + ACPI_DMT_TERMINATOR }; /* 2: ASF Remote Control */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2[] = { - {ACPI_DMT_UINT8, ACPI_ASF2_OFFSET (Controls), "Control Count"}, - {ACPI_DMT_UINT8, ACPI_ASF2_OFFSET (DataLength), "Control Data Length"}, - {ACPI_DMT_UINT16, ACPI_ASF2_OFFSET (Reserved2), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF2_OFFSET (Controls), "Control Count", 0}, + {ACPI_DMT_UINT8, ACPI_ASF2_OFFSET (DataLength), "Control Data Length", 0}, + {ACPI_DMT_UINT16, ACPI_ASF2_OFFSET (Reserved2), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; /* 2a: ASF Control data */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[] = { - {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Function), "Function"}, - {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Address), "Address"}, - {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Command), "Command"}, - {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Value), "Value"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Function), "Function", 0}, + {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Address), "Address", 0}, + {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Command), "Command", 0}, + {ACPI_DMT_UINT8, ACPI_ASF2a_OFFSET (Value), "Value", 0}, + ACPI_DMT_TERMINATOR }; /* 3: ASF RMCP Boot Options */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[] = { - {ACPI_DMT_UINT56, ACPI_ASF3_OFFSET (Capabilities[0]), "Capabilites"}, - {ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (CompletionCode), "Completion Code"}, - {ACPI_DMT_UINT32, ACPI_ASF3_OFFSET (EnterpriseId), "Enterprise ID"}, - {ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (Command), "Command"}, - {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (Parameter), "Parameter"}, - {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (BootOptions), "Boot Options"}, - {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (OemParameters), "Oem Parameters"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_BUF7, ACPI_ASF3_OFFSET (Capabilities[0]), "Capabilities", 0}, + {ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (CompletionCode), "Completion Code", 0}, + {ACPI_DMT_UINT32, ACPI_ASF3_OFFSET (EnterpriseId), "Enterprise ID", 0}, + {ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (Command), "Command", 0}, + {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (Parameter), "Parameter", 0}, + {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (BootOptions), "Boot Options", 0}, + {ACPI_DMT_UINT16, ACPI_ASF3_OFFSET (OemParameters), "Oem Parameters", 0}, + ACPI_DMT_TERMINATOR }; /* 4: ASF Address */ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[] = { - {ACPI_DMT_UINT8, ACPI_ASF4_OFFSET (EpromAddress), "Eprom Address"}, - {ACPI_DMT_UINT8, ACPI_ASF4_OFFSET (Devices), "Device Count"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_ASF4_OFFSET (EpromAddress), "Eprom Address", 0}, + {ACPI_DMT_UINT8, ACPI_ASF4_OFFSET (Devices), "Device Count", DT_COUNT}, + ACPI_DMT_TERMINATOR }; @@ -545,9 +577,9 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[] = ACPI_DMTABLE_INFO AcpiDmTableInfoBert[] = { - {ACPI_DMT_UINT32, ACPI_BERT_OFFSET (RegionLength), "Boot Error Region Length"}, - {ACPI_DMT_UINT64, ACPI_BERT_OFFSET (Address), "Boot Error Region Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_BERT_OFFSET (RegionLength), "Boot Error Region Length", 0}, + {ACPI_DMT_UINT64, ACPI_BERT_OFFSET (Address), "Boot Error Region Address", 0}, + ACPI_DMT_TERMINATOR }; @@ -559,9 +591,9 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoBert[] = ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[] = { - {ACPI_DMT_UINT8, ACPI_BOOT_OFFSET (CmosIndex), "Boot Register Index"}, - {ACPI_DMT_UINT24, ACPI_BOOT_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_BOOT_OFFSET (CmosIndex), "Boot Register Index", 0}, + {ACPI_DMT_UINT24, ACPI_BOOT_OFFSET (Reserved[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; @@ -573,18 +605,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[] = ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[] = { - {ACPI_DMT_UINT64, ACPI_CPEP_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT64, ACPI_CPEP_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[] = { - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Length), "Length"}, - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Id), "Processor ID"}, - {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Eid), "Processor EID"}, - {ACPI_DMT_UINT32, ACPI_CPEP0_OFFSET (Interval), "Polling Interval"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Header.Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Header.Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Id), "Processor ID", 0}, + {ACPI_DMT_UINT8, ACPI_CPEP0_OFFSET (Eid), "Processor EID", 0}, + {ACPI_DMT_UINT32, ACPI_CPEP0_OFFSET (Interval), "Polling Interval", 0}, + ACPI_DMT_TERMINATOR }; @@ -596,10 +628,10 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[] = { - {ACPI_DMT_UINT8, ACPI_DBGP_OFFSET (Type), "Interface Type"}, - {ACPI_DMT_UINT24, ACPI_DBGP_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_GAS, ACPI_DBGP_OFFSET (DebugPort), "Debug Port Register"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_DBGP_OFFSET (Type), "Interface Type", 0}, + {ACPI_DMT_UINT24, ACPI_DBGP_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_DBGP_OFFSET (DebugPort), "Debug Port Register", 0}, + ACPI_DMT_TERMINATOR }; @@ -611,30 +643,30 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[] = { - {ACPI_DMT_UINT8, ACPI_DMAR_OFFSET (Width), "Host Address Width"}, - {ACPI_DMT_UINT8, ACPI_DMAR_OFFSET (Flags), "Flags"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_DMAR_OFFSET (Width), "Host Address Width", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR_OFFSET (Flags), "Flags", 0}, + ACPI_DMT_TERMINATOR }; /* Common Subtable header (one per Subtable) */ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[] = { - {ACPI_DMT_DMAR, ACPI_DMAR0_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_DMAR0_OFFSET (Header.Length), "Length"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_DMAR, ACPI_DMAR0_OFFSET (Header.Type), "Subtable Type", 0}, + {ACPI_DMT_UINT16, ACPI_DMAR0_OFFSET (Header.Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR }; /* Common device scope entry */ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[] = { - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EntryType), "Device Scope Entry Type"}, - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Length), "Entry Length"}, - {ACPI_DMT_UINT16, ACPI_DMARS_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EnumerationId), "Enumeration ID"}, - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Bus), "PCI Bus Number"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EntryType), "Device Scope Entry Type", 0}, + {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Length), "Entry Length", DT_LENGTH}, + {ACPI_DMT_UINT16, ACPI_DMARS_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EnumerationId), "Enumeration ID", 0}, + {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Bus), "PCI Bus Number", 0}, + ACPI_DMT_TERMINATOR }; /* DMAR Subtables */ @@ -643,32 +675,42 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[] = { - {ACPI_DMT_UINT8, ACPI_DMAR0_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_DMAR0_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT16, ACPI_DMAR0_OFFSET (Segment), "PCI Segment Number"}, - {ACPI_DMT_UINT64, ACPI_DMAR0_OFFSET (Address), "Register Base Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_DMAR0_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_DMAR0_OFFSET (Segment), "PCI Segment Number", 0}, + {ACPI_DMT_UINT64, ACPI_DMAR0_OFFSET (Address), "Register Base Address", 0}, + ACPI_DMT_TERMINATOR }; /* 1: Reserved Memory Definition */ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[] = { - {ACPI_DMT_UINT16, ACPI_DMAR1_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT16, ACPI_DMAR1_OFFSET (Segment), "PCI Segment Number"}, - {ACPI_DMT_UINT64, ACPI_DMAR1_OFFSET (BaseAddress), "Base Address"}, - {ACPI_DMT_UINT64, ACPI_DMAR1_OFFSET (EndAddress), "End Address (limit)"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_DMAR1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_DMAR1_OFFSET (Segment), "PCI Segment Number", 0}, + {ACPI_DMT_UINT64, ACPI_DMAR1_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_DMAR1_OFFSET (EndAddress), "End Address (limit)", 0}, + ACPI_DMT_TERMINATOR }; /* 2: Root Port ATS Capability Definition */ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[] = { - {ACPI_DMT_UINT8, ACPI_DMAR2_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_DMAR2_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT16, ACPI_DMAR2_OFFSET (Segment), "PCI Segment Number"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_DMAR2_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR2_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_DMAR2_OFFSET (Segment), "PCI Segment Number", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 3: Remapping Hardware Static Affinity Structure */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[] = +{ + {ACPI_DMT_UINT32, ACPI_DMAR3_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_DMAR3_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_DMAR3_OFFSET (ProximityDomain), "Proximity Domain", 0}, + ACPI_DMT_TERMINATOR }; @@ -680,12 +722,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[] = ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[] = { - {ACPI_DMT_GAS, ACPI_ECDT_OFFSET (Control), "Command/Status Register"}, - {ACPI_DMT_GAS, ACPI_ECDT_OFFSET (Data), "Data Register"}, - {ACPI_DMT_UINT32, ACPI_ECDT_OFFSET (Uid), "UID"}, - {ACPI_DMT_UINT8, ACPI_ECDT_OFFSET (Gpe), "GPE Number"}, - {ACPI_DMT_STRING, ACPI_ECDT_OFFSET (Id[0]), "Namepath"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_GAS, ACPI_ECDT_OFFSET (Control), "Command/Status Register", 0}, + {ACPI_DMT_GAS, ACPI_ECDT_OFFSET (Data), "Data Register", 0}, + {ACPI_DMT_UINT32, ACPI_ECDT_OFFSET (Uid), "UID", 0}, + {ACPI_DMT_UINT8, ACPI_ECDT_OFFSET (Gpe), "GPE Number", 0}, + {ACPI_DMT_STRING, ACPI_ECDT_OFFSET (Id[0]), "Namepath", 0}, + ACPI_DMT_TERMINATOR }; @@ -697,22 +739,25 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[] = ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[] = { - {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (HeaderLength), "Injection Header Length"}, - {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (Entries), "Injection Entry Count"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (HeaderLength), "Injection Header Length", 0}, + {ACPI_DMT_UINT8, ACPI_EINJ_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT24, ACPI_EINJ_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_EINJ_OFFSET (Entries), "Injection Entry Count", 0}, + ACPI_DMT_TERMINATOR }; ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[] = { - {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Action), "Action"}, - {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Instruction), "Instruction"}, - {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_GAS, ACPI_EINJ0_OFFSET (RegisterRegion), "Register Region"}, - {ACPI_DMT_UINT64, ACPI_EINJ0_OFFSET (Value), "Value"}, - {ACPI_DMT_UINT64, ACPI_EINJ0_OFFSET (Mask), "Mask"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_EINJACT, ACPI_EINJ0_OFFSET (Action), "Action", 0}, + {ACPI_DMT_EINJINST, ACPI_EINJ0_OFFSET (Instruction), "Instruction", 0}, + {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_EINJ0_FLAG_OFFSET (Flags,0), "Preserve Register Bits", 0}, + + {ACPI_DMT_UINT8, ACPI_EINJ0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_EINJ0_OFFSET (RegisterRegion), "Register Region", 0}, + {ACPI_DMT_UINT64, ACPI_EINJ0_OFFSET (Value), "Value", 0}, + {ACPI_DMT_UINT64, ACPI_EINJ0_OFFSET (Mask), "Mask", 0}, + ACPI_DMT_TERMINATOR }; @@ -724,10 +769,24 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[] = ACPI_DMTABLE_INFO AcpiDmTableInfoErst[] = { - {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (HeaderLength), "Serialization Header Length"}, - {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (Entries), "Instruction Entry Count"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (HeaderLength), "Serialization Header Length", 0}, + {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_ERST_OFFSET (Entries), "Instruction Entry Count", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoErst0[] = +{ + {ACPI_DMT_ERSTACT, ACPI_ERST0_OFFSET (Action), "Action", 0}, + {ACPI_DMT_ERSTINST, ACPI_ERST0_OFFSET (Instruction), "Instruction", 0}, + {ACPI_DMT_UINT8, ACPI_ERST0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_ERST0_FLAG_OFFSET (Flags,0), "Preserve Register Bits", 0}, + + {ACPI_DMT_UINT8, ACPI_ERST0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_ERST0_OFFSET (RegisterRegion), "Register Region", 0}, + {ACPI_DMT_UINT64, ACPI_ERST0_OFFSET (Value), "Value", 0}, + {ACPI_DMT_UINT64, ACPI_ERST0_OFFSET (Mask), "Mask", 0}, + ACPI_DMT_TERMINATOR }; @@ -739,183 +798,164 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoErst[] = ACPI_DMTABLE_INFO AcpiDmTableInfoHest[] = { - {ACPI_DMT_UINT32, ACPI_HEST_OFFSET (ErrorSourceCount), "Error Source Count"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_HEST_OFFSET (ErrorSourceCount), "Error Source Count", 0}, + ACPI_DMT_TERMINATOR }; -/* HEST Subtables */ +/* Common HEST structures for subtables */ -/* 0: XPF Machine Check Exception */ +#define ACPI_DM_HEST_HEADER \ + {ACPI_DMT_HEST, ACPI_HEST0_OFFSET (Header.Type), "Subtable Type", 0}, \ + {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (Header.SourceId), "Source Id", 0} -ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[] = -{ - {ACPI_DMT_HEST, ACPI_HEST0_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Reserved1), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalCapabilityData), "Global Capability Data"}, - {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalControlData), "Global Control Data"}, - {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (NumHardwareBanks), "Num Hardware Banks"}, - {ACPI_DMT_UINT56, ACPI_HEST0_OFFSET (Reserved2), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} -}; +#define ACPI_DM_HEST_AER \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved1), "Reserved", 0}, \ + {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Flags), "Flags (decoded below)", DT_FLAG}, \ + {ACPI_DMT_FLAG0, ACPI_HEST6_FLAG_OFFSET (Aer.Flags,0), "Firmware First", 0}, \ + {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Enabled), "Enabled", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.RecordsToPreallocate), "Records To Preallocate", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.MaxSectionsPerRecord), "Max Sections Per Record", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.Bus), "Bus", 0}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Device), "Device", 0}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Function), "Function", 0}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.DeviceControl), "DeviceControl", 0}, \ + {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved2), "Reserved", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableMask), "Uncorrectable Mask", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableSeverity), "Uncorrectable Severity", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.CorrectableMask), "Correctable Mask", 0}, \ + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.AdvancedCapabilities), "Advanced Capabilities", 0} -/* 1: XPF Corrected Machine Check */ -ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[] = -{ - {ACPI_DMT_HEST, ACPI_HEST1_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST1_OFFSET (SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST1_OFFSET (ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_HESTNTFY, ACPI_HEST1_OFFSET (Notify), "Notify"}, - {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (NumHardwareBanks), "Num Hardware Banks"}, - {ACPI_DMT_UINT24, ACPI_HEST1_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} -}; +/* HEST Subtables */ -/* 3: XPF Non-Maskable Interrupt */ +/* 0: IA32 Machine Check Exception */ -ACPI_DMTABLE_INFO AcpiDmTableInfoHest3[] = +ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[] = { - {ACPI_DMT_HEST, ACPI_HEST3_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST3_OFFSET (SourceId), "Source Id"}, - {ACPI_DMT_UINT32, ACPI_HEST3_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_HEST3_OFFSET (RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST3_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT32, ACPI_HEST3_OFFSET (MaxRawDataLength), "Max Raw Data Length"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST0_OFFSET (Reserved1), "Reserved1", 0}, + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_HEST0_FLAG_OFFSET (Flags,0), "Firmware First", 0}, + + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (Enabled), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (RecordsToPreallocate), "Records To Preallocate", 0}, + {ACPI_DMT_UINT32, ACPI_HEST0_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record", 0}, + {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalCapabilityData), "Global Capability Data", 0}, + {ACPI_DMT_UINT64, ACPI_HEST0_OFFSET (GlobalControlData), "Global Control Data", 0}, + {ACPI_DMT_UINT8, ACPI_HEST0_OFFSET (NumHardwareBanks), "Num Hardware Banks", 0}, + {ACPI_DMT_UINT56, ACPI_HEST0_OFFSET (Reserved3[0]), "Reserved2", 0}, + ACPI_DMT_TERMINATOR }; -/* 4: IPF Corrected Machine Check */ +/* 1: IA32 Corrected Machine Check */ -ACPI_DMTABLE_INFO AcpiDmTableInfoHest4[] = +ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[] = { - {ACPI_DMT_HEST, ACPI_HEST4_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_HEST4_OFFSET (Enabled), "Enabled"}, - {ACPI_DMT_UINT8, ACPI_HEST4_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST1_OFFSET (Reserved1), "Reserved1", 0}, + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_HEST1_FLAG_OFFSET (Flags,0), "Firmware First", 0}, + + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (Enabled), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (RecordsToPreallocate), "Records To Preallocate", 0}, + {ACPI_DMT_UINT32, ACPI_HEST1_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record", 0}, + {ACPI_DMT_HESTNTFY, ACPI_HEST1_OFFSET (Notify), "Notify", 0}, + {ACPI_DMT_UINT8, ACPI_HEST1_OFFSET (NumHardwareBanks), "Num Hardware Banks", 0}, + {ACPI_DMT_UINT24, ACPI_HEST1_OFFSET (Reserved2[0]), "Reserved2", 0}, + ACPI_DMT_TERMINATOR }; -/* 5: IPF Corrected Platform Error */ +/* 2: IA32 Non-Maskable Interrupt */ -ACPI_DMTABLE_INFO AcpiDmTableInfoHest5[] = +ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[] = { - {ACPI_DMT_HEST, ACPI_HEST5_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_HEST5_OFFSET (Enabled), "Enabled"}, - {ACPI_DMT_UINT8, ACPI_HEST5_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (RecordsToPreallocate), "Records To Preallocate", 0}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record", 0}, + {ACPI_DMT_UINT32, ACPI_HEST2_OFFSET (MaxRawDataLength), "Max Raw Data Length", 0}, + ACPI_DMT_TERMINATOR }; /* 6: PCI Express Root Port AER */ ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[] = { - {ACPI_DMT_HEST, ACPI_HEST6_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.Bus), "Bus"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Device), "Device"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Function), "Function"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.DeviceControl), "DeviceControl"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorMask), "Uncorrectable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorSeverity), "Uncorrectable Error Severity"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.CorrectableErrorMask), "Correctable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.AdvancedErrorCapabilities), "Advanced Error Capabilities"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (RootErrorCommand), "Root Error Command"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (RootErrorCommand), "Root Error Command", 0}, + ACPI_DMT_TERMINATOR }; /* 7: PCI Express AER (AER Endpoint) */ ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[] = { - {ACPI_DMT_HEST, ACPI_HEST6_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.Bus), "Bus"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Device), "Device"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Function), "Function"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.DeviceControl), "DeviceControl"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorMask), "Uncorrectable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorSeverity), "Uncorrectable Error Severity"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.CorrectableErrorMask), "Correctable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.AdvancedErrorCapabilities), "Advanced Error Capabilities"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + ACPI_DMT_TERMINATOR }; /* 8: PCI Express/PCI-X Bridge AER */ ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[] = { - {ACPI_DMT_HEST, ACPI_HEST6_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Flags), "Flags"}, - {ACPI_DMT_UINT8, ACPI_HEST6_OFFSET (Aer.Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.Bus), "Bus"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Device), "Device"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Function), "Function"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.DeviceControl), "DeviceControl"}, - {ACPI_DMT_UINT16, ACPI_HEST6_OFFSET (Aer.Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorMask), "Uncorrectable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.UncorrectableErrorSeverity), "Uncorrectable Error Severity"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.CorrectableErrorMask), "Correctable Error Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST6_OFFSET (Aer.AdvancedErrorCapabilities), "Advanced Error Capabilities"}, - {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (SecondaryUncorrectableErrorMask), "2nd Uncorrectable Err Mask"}, - {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (SecondaryUncorrectableErrorSeverity), "2nd Uncorrectable Err Severity"}, - {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (SecondaryAdvancedCapabilities), "2nd Advanced Capabilities"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + ACPI_DM_HEST_AER, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (UncorrectableMask2), "2nd Uncorrectable Mask", 0}, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (UncorrectableSeverity2), "2nd Uncorrectable Severity", 0}, + {ACPI_DMT_UINT32, ACPI_HEST8_OFFSET (AdvancedCapabilities2), "2nd Advanced Capabilities", 0}, + ACPI_DMT_TERMINATOR }; /* 9: Generic Hardware Error Source */ ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[] = { - {ACPI_DMT_HEST, ACPI_HEST9_OFFSET (Header.Type), "Subtable Type"}, - {ACPI_DMT_UINT16, ACPI_HEST9_OFFSET (SourceId), "Source Id"}, - {ACPI_DMT_UINT16, ACPI_HEST9_OFFSET (RelatedSourceId), "Related Source Id"}, - {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (Enabled), "Enabled"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (RecordsToPreAllocate), "Records To Preallocate"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxRawDataLength), "Max Raw Data Length"}, - {ACPI_DMT_GAS, ACPI_HEST9_OFFSET (ErrorStatusAddress), "Error Status Address"}, - {ACPI_DMT_HESTNTFY, ACPI_HEST9_OFFSET (Notify), "Notify"}, - {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (ErrorStatusBlockLength), "Error Status Block Length"}, - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DM_HEST_HEADER, + {ACPI_DMT_UINT16, ACPI_HEST9_OFFSET (RelatedSourceId), "Related Source Id", 0}, + {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_HEST9_OFFSET (Enabled), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (RecordsToPreallocate), "Records To Preallocate", 0}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxSectionsPerRecord), "Max Sections Per Record", 0}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (MaxRawDataLength), "Max Raw Data Length", 0}, + {ACPI_DMT_GAS, ACPI_HEST9_OFFSET (ErrorStatusAddress), "Error Status Address", 0}, + {ACPI_DMT_HESTNTFY, ACPI_HEST9_OFFSET (Notify), "Notify", 0}, + {ACPI_DMT_UINT32, ACPI_HEST9_OFFSET (ErrorBlockLength), "Error Status Block Length", 0}, + ACPI_DMT_TERMINATOR }; -ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[10] = +ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[] = +{ + {ACPI_DMT_HESTNTYP, ACPI_HESTN_OFFSET (Type), "Notify Type", 0}, + {ACPI_DMT_UINT8, ACPI_HESTN_OFFSET (Length), "Notify Length", DT_LENGTH}, + {ACPI_DMT_UINT16, ACPI_HESTN_OFFSET (ConfigWriteEnable), "Configuration Write Enable", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollInterval), "PollInterval", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (Vector), "Vector", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollingThresholdValue), "Polling Threshold Value", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollingThresholdWindow), "Polling Threshold Window", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (ErrorThresholdValue), "Error Threshold Value", 0}, + {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (ErrorThresholdWindow), "Error Threshold Window", 0}, + ACPI_DMT_TERMINATOR +}; + + +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[] = { - {ACPI_DMT_HESTNTYP, ACPI_HESTN_OFFSET (Type), "Notify Type"}, - {ACPI_DMT_UINT8, ACPI_HESTN_OFFSET (Length), "Notify Length"}, - {ACPI_DMT_UINT16, ACPI_HESTN_OFFSET (ConfigWriteEnable), "Configuration Write Enable"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollInterval), "PollInterval"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (Vector), "Vector"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollingThresholdValue), "Polling Threshold Value"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (PollingThresholdWindow), "Polling Threshold Window"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (ErrorThresholdValue), "Error Threshold Value"}, - {ACPI_DMT_UINT32, ACPI_HESTN_OFFSET (ErrorThresholdWindow), "Error Threshold Window"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (BankNumber), "Bank Number", 0}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (ClearStatusOnInit), "Clear Status On Init", 0}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (StatusFormat), "Status Format", 0}, + {ACPI_DMT_UINT8, ACPI_HESTB_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (ControlRegister), "Control Register", 0}, + {ACPI_DMT_UINT64, ACPI_HESTB_OFFSET (ControlData), "Control Data", 0}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (StatusRegister), "Status Register", 0}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (AddressRegister), "Address Register", 0}, + {ACPI_DMT_UINT32, ACPI_HESTB_OFFSET (MiscRegister), "Misc Register", 0}, + ACPI_DMT_TERMINATOR }; @@ -927,15 +967,110 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[10] = ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[] = { - {ACPI_DMT_UINT32, ACPI_HPET_OFFSET (Id), "Hardware Block ID"}, - {ACPI_DMT_GAS, ACPI_HPET_OFFSET (Address), "Timer Block Register"}, - {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Sequence), "Sequence Number"}, - {ACPI_DMT_UINT16, ACPI_HPET_OFFSET (MinimumTick), "Minimum Clock Ticks"}, - {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_HPET_FLAG_OFFSET (Flags,0), "Page Protect"}, - {ACPI_DMT_FLAG1, ACPI_HPET_FLAG_OFFSET (Flags,0), "4K Page Protect"}, - {ACPI_DMT_FLAG2, ACPI_HPET_FLAG_OFFSET (Flags,0), "64K Page Protect"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_HPET_OFFSET (Id), "Hardware Block ID", 0}, + {ACPI_DMT_GAS, ACPI_HPET_OFFSET (Address), "Timer Block Register", 0}, + {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Sequence), "Sequence Number", 0}, + {ACPI_DMT_UINT16, ACPI_HPET_OFFSET (MinimumTick), "Minimum Clock Ticks", 0}, + {ACPI_DMT_UINT8, ACPI_HPET_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_HPET_FLAG_OFFSET (Flags,0), "4K Page Protect", 0}, + {ACPI_DMT_FLAG1, ACPI_HPET_FLAG_OFFSET (Flags,0), "64K Page Protect", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[] = +{ + {ACPI_DMT_UINT32, ACPI_IVRS_OFFSET (Info), "Virtualization Info", 0}, + {ACPI_DMT_UINT64, ACPI_IVRS_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Common Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[] = +{ + {ACPI_DMT_IVRS, ACPI_IVRSH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_IVRSH_OFFSET (Flags), "Flags", 0}, + {ACPI_DMT_UINT16, ACPI_IVRSH_OFFSET (Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT16, ACPI_IVRSH_OFFSET (DeviceId), "DeviceId", 0}, + ACPI_DMT_TERMINATOR +}; + +/* IVRS subtables */ + +/* 0x10: I/O Virtualization Hardware Definition (IVHD) Block */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[] = +{ + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (CapabilityOffset), "Capability Offset", 0}, + {ACPI_DMT_UINT64, ACPI_IVRS0_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (PciSegmentGroup), "PCI Segment Group", 0}, + {ACPI_DMT_UINT16, ACPI_IVRS0_OFFSET (Info), "Virtualization Info", 0}, + {ACPI_DMT_UINT32, ACPI_IVRS0_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition (IVMD) Block */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[] = +{ + {ACPI_DMT_UINT16, ACPI_IVRS1_OFFSET (AuxData), "Auxiliary Data", 0}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (StartAddress), "Start Address", 0}, + {ACPI_DMT_UINT64, ACPI_IVRS1_OFFSET (MemoryLength), "Memory Length", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Device entry header for IVHD block */ + +#define ACPI_DMT_IVRS_DE_HEADER \ + {ACPI_DMT_UINT8, ACPI_IVRSD_OFFSET (Type), "Entry Type", 0}, \ + {ACPI_DMT_UINT16, ACPI_IVRSD_OFFSET (Id), "Device ID", 0}, \ + {ACPI_DMT_UINT8, ACPI_IVRSD_OFFSET (DataSetting), "Data Setting", 0} + +/* 4-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_EXIT, 0, NULL, 0}, +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT8, ACPI_IVRS8A_OFFSET (Reserved1), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_IVRS8A_OFFSET (UsedId), "Source Used Device ID", 0}, + {ACPI_DMT_UINT8, ACPI_IVRS8A_OFFSET (Reserved2), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT32, ACPI_IVRS8B_OFFSET (ExtendedData), "Extended Data", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 8-byte device entry */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[] = +{ + ACPI_DMT_IVRS_DE_HEADER, + {ACPI_DMT_UINT8, ACPI_IVRS8C_OFFSET (Handle), "Handle", 0}, + {ACPI_DMT_UINT16, ACPI_IVRS8C_OFFSET (UsedId), "Source Used Device ID", 0}, + {ACPI_DMT_UINT8, ACPI_IVRS8C_OFFSET (Variety), "Variety", 0}, + ACPI_DMT_TERMINATOR }; @@ -947,19 +1082,19 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[] = { - {ACPI_DMT_UINT32, ACPI_MADT_OFFSET (Address), "Local Apic Address"}, - {ACPI_DMT_UINT32, ACPI_MADT_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_MADT_FLAG_OFFSET (Flags,0), "PC-AT Compatibility"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_MADT_OFFSET (Address), "Local Apic Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT_FLAG_OFFSET (Flags,0), "PC-AT Compatibility", 0}, + ACPI_DMT_TERMINATOR }; /* Common Subtable header (one per Subtable) */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[] = { - {ACPI_DMT_MADT, ACPI_MADTH_OFFSET (Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_MADTH_OFFSET (Length), "Length"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_MADT, ACPI_MADTH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_MADTH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR }; /* MADT Subtables */ @@ -968,135 +1103,135 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[] = { - {ACPI_DMT_UINT8, ACPI_MADT0_OFFSET (ProcessorId), "Processor ID"}, - {ACPI_DMT_UINT8, ACPI_MADT0_OFFSET (Id), "Local Apic ID"}, - {ACPI_DMT_UINT32, ACPI_MADT0_OFFSET (LapicFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_MADT0_FLAG_OFFSET (LapicFlags,0), "Processor Enabled"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT0_OFFSET (ProcessorId), "Processor ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT0_OFFSET (Id), "Local Apic ID", 0}, + {ACPI_DMT_UINT32, ACPI_MADT0_OFFSET (LapicFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT0_FLAG_OFFSET (LapicFlags,0), "Processor Enabled", 0}, + ACPI_DMT_TERMINATOR }; /* 1: IO APIC */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[] = { - {ACPI_DMT_UINT8, ACPI_MADT1_OFFSET (Id), "I/O Apic ID"}, - {ACPI_DMT_UINT8, ACPI_MADT1_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_MADT1_OFFSET (Address), "Address"}, - {ACPI_DMT_UINT32, ACPI_MADT1_OFFSET (GlobalIrqBase), "Interrupt"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT1_OFFSET (Id), "I/O Apic ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT1_OFFSET (Address), "Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT1_OFFSET (GlobalIrqBase), "Interrupt", 0}, + ACPI_DMT_TERMINATOR }; /* 2: Interrupt Override */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt2[] = { - {ACPI_DMT_UINT8, ACPI_MADT2_OFFSET (Bus), "Bus"}, - {ACPI_DMT_UINT8, ACPI_MADT2_OFFSET (SourceIrq), "Source"}, - {ACPI_DMT_UINT32, ACPI_MADT2_OFFSET (GlobalIrq), "Interrupt"}, - {ACPI_DMT_UINT16, ACPI_MADT2_OFFSET (IntiFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAGS0, ACPI_MADT2_FLAG_OFFSET (IntiFlags,0), "Polarity"}, - {ACPI_DMT_FLAGS2, ACPI_MADT2_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT2_OFFSET (Bus), "Bus", 0}, + {ACPI_DMT_UINT8, ACPI_MADT2_OFFSET (SourceIrq), "Source", 0}, + {ACPI_DMT_UINT32, ACPI_MADT2_OFFSET (GlobalIrq), "Interrupt", 0}, + {ACPI_DMT_UINT16, ACPI_MADT2_OFFSET (IntiFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAGS0, ACPI_MADT2_FLAG_OFFSET (IntiFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAGS2, ACPI_MADT2_FLAG_OFFSET (IntiFlags,0), "Trigger Mode", 0}, + ACPI_DMT_TERMINATOR }; /* 3: NMI Sources */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt3[] = { - {ACPI_DMT_UINT16, ACPI_MADT3_OFFSET (IntiFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAGS0, ACPI_MADT3_FLAG_OFFSET (IntiFlags,0), "Polarity"}, - {ACPI_DMT_FLAGS2, ACPI_MADT3_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, - {ACPI_DMT_UINT32, ACPI_MADT3_OFFSET (GlobalIrq), "Interrupt"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_MADT3_OFFSET (IntiFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAGS0, ACPI_MADT3_FLAG_OFFSET (IntiFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAGS2, ACPI_MADT3_FLAG_OFFSET (IntiFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_UINT32, ACPI_MADT3_OFFSET (GlobalIrq), "Interrupt", 0}, + ACPI_DMT_TERMINATOR }; /* 4: Local APIC NMI */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt4[] = { - {ACPI_DMT_UINT8, ACPI_MADT4_OFFSET (ProcessorId), "Processor ID"}, - {ACPI_DMT_UINT16, ACPI_MADT4_OFFSET (IntiFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAGS0, ACPI_MADT4_FLAG_OFFSET (IntiFlags,0), "Polarity"}, - {ACPI_DMT_FLAGS2, ACPI_MADT4_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, - {ACPI_DMT_UINT8, ACPI_MADT4_OFFSET (Lint), "Interrupt Input LINT"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT4_OFFSET (ProcessorId), "Processor ID", 0}, + {ACPI_DMT_UINT16, ACPI_MADT4_OFFSET (IntiFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAGS0, ACPI_MADT4_FLAG_OFFSET (IntiFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAGS2, ACPI_MADT4_FLAG_OFFSET (IntiFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_UINT8, ACPI_MADT4_OFFSET (Lint), "Interrupt Input LINT", 0}, + ACPI_DMT_TERMINATOR }; /* 5: Address Override */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[] = { - {ACPI_DMT_UINT16, ACPI_MADT5_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT64, ACPI_MADT5_OFFSET (Address), "APIC Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_MADT5_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_MADT5_OFFSET (Address), "APIC Address", 0}, + ACPI_DMT_TERMINATOR }; /* 6: I/O Sapic */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[] = { - {ACPI_DMT_UINT8, ACPI_MADT6_OFFSET (Id), "I/O Sapic ID"}, - {ACPI_DMT_UINT8, ACPI_MADT6_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_MADT6_OFFSET (GlobalIrqBase), "Interrupt Base"}, - {ACPI_DMT_UINT64, ACPI_MADT6_OFFSET (Address), "Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT6_OFFSET (Id), "I/O Sapic ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT6_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT6_OFFSET (GlobalIrqBase), "Interrupt Base", 0}, + {ACPI_DMT_UINT64, ACPI_MADT6_OFFSET (Address), "Address", 0}, + ACPI_DMT_TERMINATOR }; /* 7: Local Sapic */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[] = { - {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (ProcessorId), "Processor ID"}, - {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (Id), "Local Sapic ID"}, - {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (Eid), "Local Sapic EID"}, - {ACPI_DMT_UINT24, ACPI_MADT7_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_MADT7_OFFSET (LapicFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_MADT7_FLAG_OFFSET (LapicFlags,0), "Processor Enabled"}, - {ACPI_DMT_UINT32, ACPI_MADT7_OFFSET (Uid), "Processor UID"}, - {ACPI_DMT_STRING, ACPI_MADT7_OFFSET (UidString[0]), "Processor UID String"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (ProcessorId), "Processor ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (Id), "Local Sapic ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT7_OFFSET (Eid), "Local Sapic EID", 0}, + {ACPI_DMT_UINT24, ACPI_MADT7_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT7_OFFSET (LapicFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT7_FLAG_OFFSET (LapicFlags,0), "Processor Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_MADT7_OFFSET (Uid), "Processor UID", 0}, + {ACPI_DMT_STRING, ACPI_MADT7_OFFSET (UidString[0]), "Processor UID String", 0}, + ACPI_DMT_TERMINATOR }; /* 8: Platform Interrupt Source */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[] = { - {ACPI_DMT_UINT16, ACPI_MADT8_OFFSET (IntiFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAGS0, ACPI_MADT8_FLAG_OFFSET (IntiFlags,0), "Polarity"}, - {ACPI_DMT_FLAGS2, ACPI_MADT8_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, - {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Type), "InterruptType"}, - {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Id), "Processor ID"}, - {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Eid), "Processor EID"}, - {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (IoSapicVector), "I/O Sapic Vector"}, - {ACPI_DMT_UINT32, ACPI_MADT8_OFFSET (GlobalIrq), "Interrupt"}, - {ACPI_DMT_UINT32, ACPI_MADT8_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_MADT8_OFFSET (Flags), "CPEI Override"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_MADT8_OFFSET (IntiFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAGS0, ACPI_MADT8_FLAG_OFFSET (IntiFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAGS2, ACPI_MADT8_FLAG_OFFSET (IntiFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Type), "InterruptType", 0}, + {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Id), "Processor ID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (Eid), "Processor EID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT8_OFFSET (IoSapicVector), "I/O Sapic Vector", 0}, + {ACPI_DMT_UINT32, ACPI_MADT8_OFFSET (GlobalIrq), "Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_MADT8_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT8_OFFSET (Flags), "CPEI Override", 0}, + ACPI_DMT_TERMINATOR }; -/* 9: Processor Local X2_APIC (07/2008) */ +/* 9: Processor Local X2_APIC (ACPI 4.0) */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[] = { - {ACPI_DMT_UINT16, ACPI_MADT9_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LocalApicId), "Processor x2Apic ID"}, - {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LapicFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_MADT9_FLAG_OFFSET (LapicFlags,0), "Processor Enabled"}, - {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (Uid), "Processor UID"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_MADT9_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LocalApicId), "Processor x2Apic ID", 0}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (LapicFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT9_FLAG_OFFSET (LapicFlags,0), "Processor Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_MADT9_OFFSET (Uid), "Processor UID", 0}, + ACPI_DMT_TERMINATOR }; -/* 10: Local X2_APIC NMI (07/2008) */ +/* 10: Local X2_APIC NMI (ACPI 4.0) */ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = { - {ACPI_DMT_UINT16, ACPI_MADT10_OFFSET (IntiFlags), "Flags (decoded below)"}, - {ACPI_DMT_FLAGS0, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Polarity"}, - {ACPI_DMT_FLAGS2, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Trigger Mode"}, - {ACPI_DMT_UINT32, ACPI_MADT10_OFFSET (Uid), "Processor UID"}, - {ACPI_DMT_UINT8, ACPI_MADT10_OFFSET (Lint), "Interrupt Input LINT"}, - {ACPI_DMT_UINT24, ACPI_MADT10_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_MADT10_OFFSET (IntiFlags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAGS0, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAGS2, ACPI_MADT10_FLAG_OFFSET (IntiFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_UINT32, ACPI_MADT10_OFFSET (Uid), "Processor UID", 0}, + {ACPI_DMT_UINT8, ACPI_MADT10_OFFSET (Lint), "Interrupt Input LINT", 0}, + {ACPI_DMT_UINT24, ACPI_MADT10_OFFSET (Reserved[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; @@ -1108,18 +1243,71 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[] = { - {ACPI_DMT_UINT64, ACPI_MCFG_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT64, ACPI_MCFG_OFFSET (Reserved[0]), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[] = { - {ACPI_DMT_UINT64, ACPI_MCFG0_OFFSET (Address), "Base Address"}, - {ACPI_DMT_UINT16, ACPI_MCFG0_OFFSET (PciSegment), "Segment Group Number"}, - {ACPI_DMT_UINT8, ACPI_MCFG0_OFFSET (StartBusNumber), "Start Bus Number"}, - {ACPI_DMT_UINT8, ACPI_MCFG0_OFFSET (EndBusNumber), "End Bus Number"}, - {ACPI_DMT_UINT32, ACPI_MCFG0_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT64, ACPI_MCFG0_OFFSET (Address), "Base Address", 0}, + {ACPI_DMT_UINT16, ACPI_MCFG0_OFFSET (PciSegment), "Segment Group Number", 0}, + {ACPI_DMT_UINT8, ACPI_MCFG0_OFFSET (StartBusNumber), "Start Bus Number", 0}, + {ACPI_DMT_UINT8, ACPI_MCFG0_OFFSET (EndBusNumber), "End Bus Number", 0}, + {ACPI_DMT_UINT32, ACPI_MCFG0_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * MCHI - Management Controller Host Interface table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMchi[] = +{ + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (InterfaceType), "Interface Type", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (Protocol), "Protocol", 0}, + {ACPI_DMT_UINT64, ACPI_MCHI_OFFSET (ProtocolData), "Protocol Data", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (InterruptType), "Interrupt Type", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (Gpe), "Gpe", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (PciDeviceFlag), "Pci Device Flag", 0}, + {ACPI_DMT_UINT32, ACPI_MCHI_OFFSET (GlobalInterrupt), "Global Interrupt", 0}, + {ACPI_DMT_GAS, ACPI_MCHI_OFFSET (ControlRegister), "Control Register", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (PciSegment), "Pci Segment", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (PciBus), "Pci Bus", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (PciDevice), "Pci Device", 0}, + {ACPI_DMT_UINT8, ACPI_MCHI_OFFSET (PciFunction), "Pci Function", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[] = +{ + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (ProximityOffset), "Proximity Offset", 0}, + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (MaxProximityDomains), "Max Proximity Domains", 0}, + {ACPI_DMT_UINT32, ACPI_MSCT_OFFSET (MaxClockDomains), "Max Clock Domains", 0}, + {ACPI_DMT_UINT64, ACPI_MSCT_OFFSET (MaxAddress), "Max Physical Address", 0}, + ACPI_DMT_TERMINATOR +}; + +/* Subtable - Maximum Proximity Domain Information. Version 1 */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[] = +{ + {ACPI_DMT_UINT8, ACPI_MSCT0_OFFSET (Revision), "Revision", 0}, + {ACPI_DMT_UINT8, ACPI_MSCT0_OFFSET (Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (RangeStart), "Domain Range Start", 0}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (RangeEnd), "Domain Range End", 0}, + {ACPI_DMT_UINT32, ACPI_MSCT0_OFFSET (ProcessorCapacity), "Processor Capacity", 0}, + {ACPI_DMT_UINT64, ACPI_MSCT0_OFFSET (MemoryCapacity), "Memory Capacity", 0}, + ACPI_DMT_TERMINATOR }; @@ -1131,22 +1319,23 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[] = { - {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (WarningLevel), "Warning Level"}, - {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (LowLevel), "Low Level"}, - {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (CriticalLevel), "Critical Level"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (WarningLevel), "Warning Level", 0}, + {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (LowLevel), "Low Level", 0}, + {ACPI_DMT_UINT32, ACPI_SBST_OFFSET (CriticalLevel), "Critical Level", 0}, + ACPI_DMT_TERMINATOR }; /******************************************************************************* * - * SLIC - Software Licensing Description Table. NOT FULLY IMPLEMENTED + * SLIC - Software Licensing Description Table. NOT FULLY IMPLEMENTED, do not + * have the table definition. * ******************************************************************************/ ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[] = { - {ACPI_DMT_EXIT, 0, NULL} + ACPI_DMT_TERMINATOR }; @@ -1158,8 +1347,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[] = { - {ACPI_DMT_UINT64, ACPI_SLIT_OFFSET (LocalityCount), "Localities"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT64, ACPI_SLIT_OFFSET (LocalityCount), "Localities", 0}, + ACPI_DMT_TERMINATOR }; @@ -1171,27 +1360,27 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[] = { - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterfaceType), "Interface Type"}, - {ACPI_DMT_UINT24, ACPI_SPCR_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_GAS, ACPI_SPCR_OFFSET (SerialPort), "Serial Port Register"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterruptType), "Interrupt Type"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PcInterrupt), "PCAT-compatible IRQ"}, - {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (Interrupt), "Interrupt"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (BaudRate), "Baud Rate"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Parity), "Parity"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (StopBits), "Stop Bits"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (FlowControl), "Flow Control"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (TerminalType), "Terminal Type"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Reserved2), "Reserved"}, - {ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciDeviceId), "PCI Device ID"}, - {ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciVendorId), "PCI Vendor ID"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciBus), "PCI Bus"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciDevice), "PCI Device"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciFunction), "PCI Function"}, - {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (PciFlags), "PCI Flags"}, - {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciSegment), "PCI Segment"}, - {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (Reserved2), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterfaceType), "Interface Type", 0}, + {ACPI_DMT_UINT24, ACPI_SPCR_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_SPCR_OFFSET (SerialPort), "Serial Port Register", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterruptType), "Interrupt Type", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PcInterrupt), "PCAT-compatible IRQ", 0}, + {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (Interrupt), "Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (BaudRate), "Baud Rate", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Parity), "Parity", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (StopBits), "Stop Bits", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (FlowControl), "Flow Control", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (TerminalType), "Terminal Type", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Reserved2), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciDeviceId), "PCI Device ID", 0}, + {ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciVendorId), "PCI Vendor ID", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciBus), "PCI Bus", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciDevice), "PCI Device", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciFunction), "PCI Function", 0}, + {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (PciFlags), "PCI Flags", 0}, + {ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciSegment), "PCI Segment", 0}, + {ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (Reserved2), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; @@ -1203,20 +1392,21 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] = { - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterfaceType), "Interface Type"}, - {ACPI_DMT_UINT16, ACPI_SPMI_OFFSET (SpecRevision), "IPMI Spec Version"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterruptType), "Interrupt Type"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (GpeNumber), "GPE Number"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved1), "Reserved"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDeviceFlag), "PCI Device Flag"}, - {ACPI_DMT_UINT32, ACPI_SPMI_OFFSET (Interrupt), "Interrupt"}, - {ACPI_DMT_GAS, ACPI_SPMI_OFFSET (IpmiRegister), "IPMI Register"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciSegment), "PCI Segment"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciBus), "PCI Bus"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDevice), "PCI Device"}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciFunction), "PCI Function"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterfaceType), "Interface Type", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_SPMI_OFFSET (SpecRevision), "IPMI Spec Version", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterruptType), "Interrupt Type", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (GpeNumber), "GPE Number", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved1), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDeviceFlag), "PCI Device Flag", 0}, + {ACPI_DMT_UINT32, ACPI_SPMI_OFFSET (Interrupt), "Interrupt", 0}, + {ACPI_DMT_GAS, ACPI_SPMI_OFFSET (IpmiRegister), "IPMI Register", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciSegment), "PCI Segment", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciBus), "PCI Bus", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDevice), "PCI Device", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciFunction), "PCI Function", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved2), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; @@ -1228,18 +1418,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[] = { - {ACPI_DMT_UINT32, ACPI_SRAT_OFFSET (TableRevision), "Table Revision"}, - {ACPI_DMT_UINT64, ACPI_SRAT_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_SRAT_OFFSET (TableRevision), "Table Revision", 0}, + {ACPI_DMT_UINT64, ACPI_SRAT_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; /* Common Subtable header (one per Subtable) */ ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[] = { - {ACPI_DMT_SRAT, ACPI_SRATH_OFFSET (Type), "Subtable Type"}, - {ACPI_DMT_UINT8, ACPI_SRATH_OFFSET (Length), "Length"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_SRAT, ACPI_SRATH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_SRATH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR }; /* SRAT Subtables */ @@ -1248,43 +1438,45 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] = { - {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ProximityDomainLo), "Proximity Domain Low(8)"}, - {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ApicId), "Apic ID"}, - {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_SRAT0_FLAG_OFFSET (Flags,0), "Enabled"}, - {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (LocalSapicEid), "Local Sapic EID"}, - {ACPI_DMT_UINT24, ACPI_SRAT0_OFFSET (ProximityDomainHi[0]), "Proximity Domain High(24)"}, - {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ProximityDomainLo), "Proximity Domain Low(8)", 0}, + {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ApicId), "Apic ID", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_SRAT0_FLAG_OFFSET (Flags,0), "Enabled", 0}, + {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (LocalSapicEid), "Local Sapic EID", 0}, + {ACPI_DMT_UINT24, ACPI_SRAT0_OFFSET (ProximityDomainHi[0]), "Proximity Domain High(24)", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Reserved), "Reserved", 0}, + ACPI_DMT_TERMINATOR }; /* 1: Memory Affinity */ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[] = { - {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (ProximityDomain), "Proximity Domain"}, - {ACPI_DMT_UINT16, ACPI_SRAT1_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (BaseAddress), "Base Address"}, - {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Length), "Address Length"}, - {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Reserved1), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Enabled"}, - {ACPI_DMT_FLAG1, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Hot Pluggable"}, - {ACPI_DMT_FLAG2, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Non-Volatile"}, - {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Reserved2), "Reserved"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (ProximityDomain), "Proximity Domain", 0}, + {ACPI_DMT_UINT16, ACPI_SRAT1_OFFSET (Reserved), "Reserved1", 0}, + {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Length), "Address Length", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Reserved1), "Reserved2", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Enabled", 0}, + {ACPI_DMT_FLAG1, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Hot Pluggable", 0}, + {ACPI_DMT_FLAG2, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Non-Volatile", 0}, + {ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Reserved2), "Reserved3", 0}, + ACPI_DMT_TERMINATOR }; -/* 2: Processor Local X2_APIC Affinity (07/2008) */ +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] = { - {ACPI_DMT_UINT16, ACPI_SRAT2_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ProximityDomain), "Proximity Domain"}, - {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ApicId), "Apic ID"}, - {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_SRAT2_FLAG_OFFSET (Flags,0), "Enabled"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_SRAT2_OFFSET (Reserved), "Reserved1", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ProximityDomain), "Proximity Domain", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ApicId), "Apic ID", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_SRAT2_FLAG_OFFSET (Flags,0), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ClockDomain), "Clock Domain", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Reserved2), "Reserved2", 0}, + ACPI_DMT_TERMINATOR }; @@ -1296,10 +1488,118 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] = ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = { - {ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (Reserved), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_TCPA_OFFSET (MaxLogLength), "Max Event Log Length"}, - {ACPI_DMT_UINT64, ACPI_TCPA_OFFSET (LogAddress), "Event Log Address"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_TCPA_OFFSET (MaxLogLength), "Max Event Log Length", 0}, + {ACPI_DMT_UINT64, ACPI_TCPA_OFFSET (LogAddress), "Event Log Address", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[] = +{ + {ACPI_DMT_UUID, ACPI_UEFI_OFFSET (Identifier[0]), "UUID Identifier", 0}, + {ACPI_DMT_UINT16, ACPI_UEFI_OFFSET (DataOffset), "Data Offset", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[] = +{ + {ACPI_DMT_UINT32, ACPI_WAET_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_WAET_OFFSET (Flags), "RTC needs no INT ack", 0}, + {ACPI_DMT_FLAG1, ACPI_WAET_OFFSET (Flags), "PM timer, one read only", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[] = +{ + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (HeaderLength), "Header Length", DT_LENGTH}, + {ACPI_DMT_UINT16, ACPI_WDAT_OFFSET (PciSegment), "PCI Segment", 0}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciBus), "PCI Bus", 0}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciDevice), "PCI Device", 0}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciFunction), "PCI Function", 0}, + {ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (TimerPeriod), "Timer Period", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MaxCount), "Max Count", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MinCount), "Min Count", 0}, + {ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_WDAT_OFFSET (Flags), "Enabled", 0}, + {ACPI_DMT_FLAG7, ACPI_WDAT_OFFSET (Flags), "Stopped When Asleep", 0}, + {ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved2[0]), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (Entries), "Watchdog Entry Count", 0}, + ACPI_DMT_TERMINATOR +}; + +/* WDAT Subtables - Watchdog Instruction Entries */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[] = +{ + {ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Action), "Watchdog Action", 0}, + {ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Instruction), "Instruction", 0}, + {ACPI_DMT_UINT16, ACPI_WDAT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_GAS, ACPI_WDAT0_OFFSET (RegisterRegion), "Register Region", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Value), "Value", 0}, + {ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Mask), "Register Mask", 0}, + ACPI_DMT_TERMINATOR +}; + + +/******************************************************************************* + * + * WDDT - Watchdog Description Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoWddt[] = +{ + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (SpecVersion), "Specification Version", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (TableVersion), "Table Version", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (PciVendorId), "PCI Vendor ID", 0}, + {ACPI_DMT_GAS, ACPI_WDDT_OFFSET (Address), "Timer Register", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (MaxCount), "Max Count", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (MinCount), "Min Count", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Period), "Period", 0}, + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Status), "Status (decoded below)", 0}, + + /* Status Flags byte 0 */ + + {ACPI_DMT_FLAG0, ACPI_WDDT_FLAG_OFFSET (Status,0), "Available", 0}, + {ACPI_DMT_FLAG1, ACPI_WDDT_FLAG_OFFSET (Status,0), "Active", 0}, + {ACPI_DMT_FLAG2, ACPI_WDDT_FLAG_OFFSET (Status,0), "OS Owns", 0}, + + /* Status Flags byte 1 */ + + {ACPI_DMT_FLAG3, ACPI_WDDT_FLAG_OFFSET (Status,1), "User Reset", 0}, + {ACPI_DMT_FLAG4, ACPI_WDDT_FLAG_OFFSET (Status,1), "Timeout Reset", 0}, + {ACPI_DMT_FLAG5, ACPI_WDDT_FLAG_OFFSET (Status,1), "Power Fail Reset", 0}, + {ACPI_DMT_FLAG6, ACPI_WDDT_FLAG_OFFSET (Status,1), "Unknown Reset", 0}, + + {ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Capability), "Capability (decoded below)", 0}, + + /* Capability Flags byte 0 */ + + {ACPI_DMT_FLAG0, ACPI_WDDT_FLAG_OFFSET (Capability,0), "Auto Reset", 0}, + {ACPI_DMT_FLAG1, ACPI_WDDT_FLAG_OFFSET (Capability,0), "Timeout Alert", 0}, + ACPI_DMT_TERMINATOR }; @@ -1311,19 +1611,55 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] = ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[] = { - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (HeaderLength), "Header Length"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciSegment), "PCI Segment"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciBus), "PCI Bus"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciDevice), "PCI Device"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciFunction), "PCI Function"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (TimerPeriod), "Timer Period"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (MaxCount), "Max Count"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (MinCount), "Min Count"}, - {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (Flags), "Flags (decoded below)"}, - {ACPI_DMT_FLAG0, ACPI_WDRT_OFFSET (Flags), "Enabled"}, - {ACPI_DMT_FLAG7, ACPI_WDRT_OFFSET (Flags), "Stopped When Asleep"}, - {ACPI_DMT_UINT24, ACPI_WDRT_OFFSET (Reserved[0]), "Reserved"}, - {ACPI_DMT_UINT32, ACPI_WDRT_OFFSET (Entries), "Watchdog Entries"}, - {ACPI_DMT_EXIT, 0, NULL} + {ACPI_DMT_GAS, ACPI_WDRT_OFFSET (ControlRegister), "Control Register", 0}, + {ACPI_DMT_GAS, ACPI_WDRT_OFFSET (CountRegister), "Count Register", 0}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciDeviceId), "PCI Device ID", 0}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciVendorId), "PCI Vendor ID", 0}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciBus), "PCI Bus", 0}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciDevice), "PCI Device", 0}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciFunction), "PCI Function", 0}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciSegment), "PCI Segment", 0}, + {ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (MaxCount), "Max Count", 0}, + {ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (Units), "Counter Units", 0}, + ACPI_DMT_TERMINATOR }; +/* + * Generic types (used in UEFI) + * + * Examples: + * + * Buffer : cc 04 ff bb + * UINT8 : 11 + * UINT16 : 1122 + * UINT24 : 112233 + * UINT32 : 11223344 + * UINT56 : 11223344556677 + * UINT64 : 1122334455667788 + * + * String : "This is string" + * Unicode : "This string encoded to Unicode" + * + * GUID : 11223344-5566-7788-99aa-bbccddeeff00 + * DevicePath : "\PciRoot(0)\Pci(0x1f,1)\Usb(0,0)" + */ + +#define ACPI_DM_GENERIC_ENTRY(FieldType, FieldName)\ + {{FieldType, 0, FieldName, 0}, ACPI_DMT_TERMINATOR} + +ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2] = +{ + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT8, "UINT8"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT16, "UINT16"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT24, "UINT24"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT32, "UINT32"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT56, "UINT56"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT64, "UINT64"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_STRING, "String"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UNICODE, "Unicode"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_BUFFER, "Buffer"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UUID, "GUID"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_STRING, "DevicePath"), + ACPI_DM_GENERIC_ENTRY (ACPI_DMT_LABEL, "Label"), + {ACPI_DMT_TERMINATOR} +}; diff --git a/sys/contrib/dev/acpica-unix/common/getopt.c b/sys/contrib/dev/acpica-unix/common/getopt.c index 54cff3ec2d..aaca1ffe27 100644 --- a/sys/contrib/dev/acpica-unix/common/getopt.c +++ b/sys/contrib/dev/acpica-unix/common/getopt.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -126,7 +126,6 @@ int AcpiGbl_Opterr = 1; int AcpiGbl_Optind = 1; -int AcpiGbl_Optopt; char *AcpiGbl_Optarg; @@ -171,9 +170,7 @@ AcpiGetopt( /* Get the option */ - CurrentChar = - AcpiGbl_Optopt = - argv[AcpiGbl_Optind][CurrentCharPtr]; + CurrentChar = argv[AcpiGbl_Optind][CurrentCharPtr]; /* Make sure that the option is legal */ @@ -195,9 +192,9 @@ AcpiGetopt( if (*++OptsPtr == ':') { - if (argv[AcpiGbl_Optind][CurrentCharPtr+1] != '\0') + if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0') { - AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][CurrentCharPtr+1]; + AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)]; } else if (++AcpiGbl_Optind >= argc) { @@ -218,9 +215,9 @@ AcpiGetopt( else if (*OptsPtr == '^') { - if (argv[AcpiGbl_Optind][CurrentCharPtr+1] != '\0') + if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0') { - AcpiGbl_Optarg = &argv[AcpiGbl_Optind][CurrentCharPtr+1]; + AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)]; } else { diff --git a/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c b/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c index d44adda8ff..ad0dd64a5d 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c @@ -1,7 +1,6 @@ - /****************************************************************************** * - * Module Name: aslanalyze.c - check for semantic errors + * Module Name: aslanalyze.c - Support functions for parse tree walks * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,75 +116,18 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" -#include "acparser.h" -#include "amlcode.h" +#include + #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslanalyze") -/* Local prototypes */ - -static UINT32 -AnMapArgTypeToBtype ( - UINT32 ArgType); - -static UINT32 -AnMapEtypeToBtype ( - UINT32 Etype); - -static void -AnFormatBtype ( - char *Buffer, - UINT32 Btype); - -static UINT32 -AnGetBtype ( - ACPI_PARSE_OBJECT *Op); - -static UINT32 -AnCheckForReservedName ( - ACPI_PARSE_OBJECT *Op, - char *Name); - -static void -AnCheckForReservedMethod ( - ACPI_PARSE_OBJECT *Op, - ASL_METHOD_INFO *MethodInfo); - -static UINT32 -AnMapObjTypeToBtype ( - ACPI_PARSE_OBJECT *Op); - -static BOOLEAN -AnLastStatementIsReturn ( - ACPI_PARSE_OBJECT *Op); - -static void -AnCheckMethodReturnValue ( - ACPI_PARSE_OBJECT *Op, - const ACPI_OPCODE_INFO *OpInfo, - ACPI_PARSE_OBJECT *ArgOp, - UINT32 RequiredBtypes, - UINT32 ThisNodeBtype); - -static BOOLEAN -AnIsInternalMethod ( - ACPI_PARSE_OBJECT *Op); - -static UINT32 -AnGetInternalMethodReturnType ( - ACPI_PARSE_OBJECT *Op); - -BOOLEAN -AnIsResultUsed ( - ACPI_PARSE_OBJECT *Op); - /******************************************************************************* * * FUNCTION: AnIsInternalMethod * - * PARAMETERS: Op - Current op + * PARAMETERS: Op - Current op * * RETURN: Boolean * @@ -193,7 +135,7 @@ AnIsResultUsed ( * ******************************************************************************/ -static BOOLEAN +BOOLEAN AnIsInternalMethod ( ACPI_PARSE_OBJECT *Op) { @@ -212,7 +154,7 @@ AnIsInternalMethod ( * * FUNCTION: AnGetInternalMethodReturnType * - * PARAMETERS: Op - Current op + * PARAMETERS: Op - Current op * * RETURN: Btype * @@ -220,7 +162,7 @@ AnIsInternalMethod ( * ******************************************************************************/ -static UINT32 +UINT32 AnGetInternalMethodReturnType ( ACPI_PARSE_OBJECT *Op) { @@ -237,2023 +179,379 @@ AnGetInternalMethodReturnType ( /******************************************************************************* * - * FUNCTION: AnMapArgTypeToBtype + * FUNCTION: AnCheckId * - * PARAMETERS: ArgType - The ARGI required type(s) for this argument, - * from the opcode info table + * PARAMETERS: Op - Current parse op + * Type - HID or CID * - * RETURN: The corresponding Bit-encoded types + * RETURN: None * - * DESCRIPTION: Convert an encoded ARGI required argument type code into a - * bitfield type code. Implements the implicit source conversion - * rules. + * DESCRIPTION: Perform various checks on _HID and _CID strings. Only limited + * checks can be performed on _CID strings. * ******************************************************************************/ -static UINT32 -AnMapArgTypeToBtype ( - UINT32 ArgType) +void +AnCheckId ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAME Type) { + UINT32 i; + ACPI_SIZE Length; + UINT32 AlphaPrefixLength; - switch (ArgType) - { - - /* Simple types */ - - case ARGI_ANYTYPE: - return (ACPI_BTYPE_OBJECTS_AND_REFS); - case ARGI_PACKAGE: - return (ACPI_BTYPE_PACKAGE); + /* Only care about string versions of _HID/_CID (integers are legal) */ - case ARGI_EVENT: - return (ACPI_BTYPE_EVENT); + if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL) + { + return; + } - case ARGI_MUTEX: - return (ACPI_BTYPE_MUTEX); + /* For both _HID and _CID, the string must be non-null */ - case ARGI_DDBHANDLE: - /* - * DDBHandleObject := SuperName - * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload - */ - return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE); + Length = strlen (Op->Asl.Value.String); + if (!Length) + { + AslError (ASL_ERROR, ASL_MSG_NULL_STRING, + Op, NULL); + return; + } - /* Interchangeable types */ /* - * Source conversion rules: - * Integer, String, and Buffer are all interchangeable + * One of the things we want to catch here is the use of a leading + * asterisk in the string -- an odd construct that certain platform + * manufacturers are fond of. Technically, a leading asterisk is OK + * for _CID, but a valid use of this has not been seen. */ - case ARGI_INTEGER: - case ARGI_STRING: - case ARGI_BUFFER: - case ARGI_BUFFER_OR_STRING: - case ARGI_COMPUTEDATA: - return (ACPI_BTYPE_COMPUTE_DATA); - - /* References */ - - case ARGI_INTEGER_REF: - return (ACPI_BTYPE_INTEGER); - - case ARGI_OBJECT_REF: - return (ACPI_BTYPE_ALL_OBJECTS); - - case ARGI_DEVICE_REF: - return (ACPI_BTYPE_DEVICE_OBJECTS); - - case ARGI_REFERENCE: - return (ACPI_BTYPE_REFERENCE); - - case ARGI_TARGETREF: - case ARGI_FIXED_TARGET: - case ARGI_SIMPLE_TARGET: - return (ACPI_BTYPE_OBJECTS_AND_REFS); - - /* Complex types */ - - case ARGI_DATAOBJECT: + if (*Op->Asl.Value.String == '*') + { + AslError (ASL_ERROR, ASL_MSG_LEADING_ASTERISK, + Op, Op->Asl.Value.String); + return; + } - /* - * Buffer, string, package or reference to a Op - - * Used only by SizeOf operator - */ - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + /* _CID strings are bus-specific, no more checks can be performed */ - case ARGI_COMPLEXOBJ: + if (Type == ASL_TYPE_CID) + { + return; + } - /* Buffer, String, or package */ + /* For _HID, all characters must be alphanumeric */ - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); + for (i = 0; Op->Asl.Value.String[i]; i++) + { + if (!isalnum ((int) Op->Asl.Value.String[i])) + { + AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, + Op, Op->Asl.Value.String); + break; + } + } - case ARGI_REF_OR_STRING: - return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); + /* _HID String must be of the form "XXX####" or "ACPI####" */ - case ARGI_REGION_OR_BUFFER: + if ((Length < 7) || (Length > 8)) + { + AslError (ASL_ERROR, ASL_MSG_HID_LENGTH, + Op, Op->Asl.Value.String); + return; + } - /* Used by Load() only. Allow buffers in addition to regions/fields */ + /* _HID Length is valid, now check for uppercase (first 3 or 4 chars) */ - return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); + AlphaPrefixLength = 3; + if (Length >= 8) + { + AlphaPrefixLength = 4; + } - case ARGI_DATAREFOBJ: - return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + /* Ensure the alphabetic prefix is all uppercase */ - default: - break; + for (i = 0; (i < AlphaPrefixLength) && Op->Asl.Value.String[i]; i++) + { + if (!isupper ((int) Op->Asl.Value.String[i])) + { + AslError (ASL_ERROR, ASL_MSG_UPPER_CASE, + Op, &Op->Asl.Value.String[i]); + break; + } } - - return (ACPI_BTYPE_OBJECTS_AND_REFS); } /******************************************************************************* * - * FUNCTION: AnMapEtypeToBtype + * FUNCTION: AnLastStatementIsReturn * - * PARAMETERS: Etype - Encoded ACPI Type + * PARAMETERS: Op - A method parse node * - * RETURN: Btype corresponding to the Etype + * RETURN: TRUE if last statement is an ASL RETURN. False otherwise * - * DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the - * operand conversion rules. In other words, returns the type(s) - * this Etype is implicitly converted to during interpretation. + * DESCRIPTION: Walk down the list of top level statements within a method + * to find the last one. Check if that last statement is in + * fact a RETURN statement. * ******************************************************************************/ -static UINT32 -AnMapEtypeToBtype ( - UINT32 Etype) +BOOLEAN +AnLastStatementIsReturn ( + ACPI_PARSE_OBJECT *Op) { + ACPI_PARSE_OBJECT *Next; - if (Etype == ACPI_TYPE_ANY) - { - return ACPI_BTYPE_OBJECTS_AND_REFS; - } - - /* Try the standard ACPI data types */ + /* Check if last statement is a return */ - if (Etype <= ACPI_TYPE_EXTERNAL_MAX) + Next = ASL_GET_CHILD_NODE (Op); + while (Next) { - /* - * This switch statement implements the allowed operand conversion - * rules as per the "ASL Data Types" section of the ACPI - * specification. - */ - switch (Etype) + if ((!Next->Asl.Next) && + (Next->Asl.ParseOpcode == PARSEOP_RETURN)) { - case ACPI_TYPE_INTEGER: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE); - - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - return (ACPI_BTYPE_COMPUTE_DATA); - - case ACPI_TYPE_PACKAGE: - return (ACPI_BTYPE_PACKAGE); - - case ACPI_TYPE_FIELD_UNIT: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); - - case ACPI_TYPE_BUFFER_FIELD: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD); - - case ACPI_TYPE_DDB_HANDLE: - return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); - - case ACPI_BTYPE_DEBUG_OBJECT: - - /* Cannot be used as a source operand */ - - return (0); - - default: - return (1 << (Etype - 1)); + return (TRUE); } - } - - /* Try the internal data types */ - - switch (Etype) - { - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - /* Named fields can be either Integer/Buffer/String */ - - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); - - case ACPI_TYPE_LOCAL_ALIAS: - - return (ACPI_BTYPE_INTEGER); - - case ACPI_TYPE_LOCAL_RESOURCE: - case ACPI_TYPE_LOCAL_RESOURCE_FIELD: - - return (ACPI_BTYPE_REFERENCE); - - default: - printf ("Unhandled encoded type: %X\n", Etype); - return (0); + Next = ASL_GET_PEER_NODE (Next); } + + return (FALSE); } /******************************************************************************* * - * FUNCTION: AnFormatBtype + * FUNCTION: AnCheckMethodReturnValue * - * PARAMETERS: Btype - Bitfield of ACPI types - * Buffer - Where to put the ascii string + * PARAMETERS: Op - Parent + * OpInfo - Parent info + * ArgOp - Method invocation op + * RequiredBtypes - What caller requires + * ThisNodeBtype - What this node returns (if anything) * - * RETURN: None. + * RETURN: None * - * DESCRIPTION: Convert a Btype to a string of ACPI types + * DESCRIPTION: Check a method invocation for 1) A return value and if it does + * in fact return a value, 2) check the type of the return value. * ******************************************************************************/ -static void -AnFormatBtype ( - char *Buffer, - UINT32 Btype) +void +AnCheckMethodReturnValue ( + ACPI_PARSE_OBJECT *Op, + const ACPI_OPCODE_INFO *OpInfo, + ACPI_PARSE_OBJECT *ArgOp, + UINT32 RequiredBtypes, + UINT32 ThisNodeBtype) { - UINT32 Type; - BOOLEAN First = TRUE; + ACPI_PARSE_OBJECT *OwningOp; + ACPI_NAMESPACE_NODE *Node; - *Buffer = 0; + Node = ArgOp->Asl.Node; - if (Btype == 0) - { - strcat (Buffer, "NoReturnValue"); - return; - } - for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++) - { - if (Btype & 0x00000001) - { - if (!First) - { - strcat (Buffer, "|"); - } - First = FALSE; - strcat (Buffer, AcpiUtGetTypeName (Type)); - } - Btype >>= 1; - } + /* Examine the parent op of this method */ - if (Btype & 0x00000001) + OwningOp = Node->Op; + if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL) { - if (!First) - { - strcat (Buffer, "|"); - } - First = FALSE; - strcat (Buffer, "Reference"); + /* Method NEVER returns a value */ + + AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName); } + else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL) + { + /* Method SOMETIMES returns a value, SOMETIMES not */ - Btype >>= 1; - if (Btype & 0x00000001) + AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); + } + else if (!(ThisNodeBtype & RequiredBtypes)) { - if (!First) + /* Method returns a value, but the type is wrong */ + + AnFormatBtype (StringBuffer, ThisNodeBtype); + AnFormatBtype (StringBuffer2, RequiredBtypes); + + /* + * The case where the method does not return any value at all + * was already handled in the namespace cross reference + * -- Only issue an error if the method in fact returns a value, + * but it is of the wrong type + */ + if (ThisNodeBtype != 0) { - strcat (Buffer, "|"); + sprintf (MsgBuffer, + "Method returns [%s], %s operator requires [%s]", + StringBuffer, OpInfo->Name, StringBuffer2); + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); } - First = FALSE; - strcat (Buffer, "Resource"); } } /******************************************************************************* * - * FUNCTION: AnGetBtype + * FUNCTION: AnIsResultUsed * - * PARAMETERS: Op - Parse node whose type will be returned. + * PARAMETERS: Op - Parent op for the operator * - * RETURN: The Btype associated with the Op. + * RETURN: TRUE if result from this operation is actually consumed * - * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node. - * Handles the case where the node is a name or method call and - * the actual type must be obtained from the namespace node. + * DESCRIPTION: Determine if the function result value from an operator is + * used. * ******************************************************************************/ -static UINT32 -AnGetBtype ( +BOOLEAN +AnIsResultUsed ( ACPI_PARSE_OBJECT *Op) { - ACPI_NAMESPACE_NODE *Node; - ACPI_PARSE_OBJECT *ReferencedNode; - UINT32 ThisNodeBtype = 0; + ACPI_PARSE_OBJECT *Parent; - if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || - (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || - (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) + switch (Op->Asl.ParseOpcode) { - Node = Op->Asl.Node; - if (!Node) - { - DbgPrint (ASL_DEBUG_OUTPUT, - "No attached Nsnode: [%s] at line %d name [%s], ignoring typecheck\n", - Op->Asl.ParseOpName, Op->Asl.LineNumber, - Op->Asl.ExternalName); - return ACPI_UINT32_MAX; - } + case PARSEOP_INCREMENT: + case PARSEOP_DECREMENT: + + /* These are standalone operators, no return value */ - ThisNodeBtype = AnMapEtypeToBtype (Node->Type); - if (!ThisNodeBtype) + return (TRUE); + + default: + break; + } + + /* Examine parent to determine if the return value is used */ + + Parent = Op->Asl.Parent; + switch (Parent->Asl.ParseOpcode) + { + /* If/While - check if the operator is the predicate */ + + case PARSEOP_IF: + case PARSEOP_WHILE: + + /* First child is the predicate */ + + if (Parent->Asl.Child == Op) { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, - "could not map type"); + return (TRUE); } + return (FALSE); - /* - * Since it was a named reference, enable the - * reference bit also - */ - ThisNodeBtype |= ACPI_BTYPE_REFERENCE; + /* Not used if one of these is the parent */ - if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) - { - ReferencedNode = Node->Op; - if (!ReferencedNode) - { - /* Check for an internal method */ + case PARSEOP_METHOD: + case PARSEOP_DEFINITIONBLOCK: + case PARSEOP_ELSE: - if (AnIsInternalMethod (Op)) - { - return (AnGetInternalMethodReturnType (Op)); - } + return (FALSE); - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, - "null Op pointer"); - return ACPI_UINT32_MAX; - } + default: + /* Any other type of parent means that the result is used */ - if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED) - { - ThisNodeBtype = ReferencedNode->Asl.AcpiBtype; - } - else - { - return (ACPI_UINT32_MAX -1); - } - } - } - else - { - ThisNodeBtype = Op->Asl.AcpiBtype; + return (TRUE); } - - return (ThisNodeBtype); } /******************************************************************************* * - * FUNCTION: AnCheckForReservedName + * FUNCTION: ApCheckForGpeNameConflict * - * PARAMETERS: Op - A parse node - * Name - NameSeg to check + * PARAMETERS: Op - Current parse op * * RETURN: None * - * DESCRIPTION: Check a NameSeg against the reserved list. + * DESCRIPTION: Check for a conflict between GPE names within this scope. + * Conflict means two GPE names with the same GPE number, but + * different types -- such as _L1C and _E1C. * ******************************************************************************/ -static UINT32 -AnCheckForReservedName ( - ACPI_PARSE_OBJECT *Op, - char *Name) +void +ApCheckForGpeNameConflict ( + ACPI_PARSE_OBJECT *Op) { - UINT32 i; + ACPI_PARSE_OBJECT *NextOp; + UINT32 GpeNumber; + char Name[ACPI_NAME_SIZE + 1]; + char Target[ACPI_NAME_SIZE]; - if (Name[0] == 0) - { - AcpiOsPrintf ("Found a null name, external = %s\n", - Op->Asl.ExternalName); - } + /* Need a null-terminated string version of NameSeg */ - /* All reserved names are prefixed with a single underscore */ + ACPI_MOVE_32_TO_32 (Name, &Op->Asl.NameSeg); + Name[ACPI_NAME_SIZE] = 0; - if (Name[0] != '_') + /* + * For a GPE method: + * 1st char must be underscore + * 2nd char must be L or E + * 3rd/4th chars must be a hex number + */ + if ((Name[0] != '_') || + ((Name[1] != 'L') && (Name[1] != 'E'))) { - return (ACPI_NOT_RESERVED_NAME); + return; } - /* Check for a standard reserved method name */ + /* Verify 3rd/4th chars are a valid hex value */ - for (i = 0; ReservedMethods[i].Name; i++) + GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) { - if (ACPI_COMPARE_NAME (Name, ReservedMethods[i].Name)) - { - if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) - { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, - Op->Asl.ExternalName); - return (ACPI_PREDEFINED_NAME); - } - else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) - { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, - Op->Asl.ExternalName); - return (ACPI_PREDEFINED_NAME); - } - - /* Return index into reserved array */ - - return i; - } + return; } /* - * Now check for the "special" reserved names -- - * GPE: _Lxx - * GPE: _Exx - * EC: _Qxx + * We are now sure we have an _Lxx or _Exx. + * Create the target name that would cause collision (Flip E/L) */ - if ((Name[1] == 'L') || - (Name[1] == 'E') || - (Name[1] == 'Q')) - { - /* The next two characters must be hex digits */ - - if ((isxdigit (Name[2])) && - (isxdigit (Name[3]))) - { - return (ACPI_EVENT_RESERVED_NAME); - } - } + ACPI_MOVE_32_TO_32 (Target, Name); + /* Inject opposite letter ("L" versus "E") */ - /* Check for the names reserved for the compiler itself: _T_x */ - - else if ((Op->Asl.ExternalName[1] == 'T') && - (Op->Asl.ExternalName[2] == '_')) - { - /* Ignore if actually emitted by the compiler */ - - if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED) - { - return (ACPI_NOT_RESERVED_NAME); - } - - /* - * Was not actually emitted by the compiler. This is a special case, - * however. If the ASL code being compiled was the result of a - * dissasembly, it may possibly contain valid compiler-emitted names - * of the form "_T_x". We don't want to issue an error or even a - * warning and force the user to manually change the names. So, we - * will issue a remark instead. - */ - AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); - return (ACPI_COMPILER_RESERVED_NAME); - } - - /* - * The name didn't match any of the known reserved names. Flag it as a - * warning, since the entire namespace starting with an underscore is - * reserved by the ACPI spec. - */ - AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, - Op->Asl.ExternalName); - - return (ACPI_NOT_RESERVED_NAME); -} - - -/******************************************************************************* - * - * FUNCTION: AnCheckForReservedMethod - * - * PARAMETERS: Op - A parse node of type "METHOD". - * MethodInfo - Saved info about this method - * - * RETURN: None - * - * DESCRIPTION: If method is a reserved name, check that the number of arguments - * and the return type (returns a value or not) is correct. - * - ******************************************************************************/ - -static void -AnCheckForReservedMethod ( - ACPI_PARSE_OBJECT *Op, - ASL_METHOD_INFO *MethodInfo) -{ - UINT32 Index; - UINT32 RequiredArgsCurrent; - UINT32 RequiredArgsOld; - - - /* Check for a match against the reserved name list */ - - Index = AnCheckForReservedName (Op, Op->Asl.NameSeg); - - switch (Index) + if (Name[1] == 'L') { - case ACPI_NOT_RESERVED_NAME: - case ACPI_PREDEFINED_NAME: - case ACPI_COMPILER_RESERVED_NAME: - - /* Just return, nothing to do */ - break; - - - case ACPI_EVENT_RESERVED_NAME: - - Gbl_ReservedMethods++; - - /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */ - - if (MethodInfo->NumArguments != 0) - { - sprintf (MsgBuffer, "%s requires %d", - Op->Asl.ExternalName, 0); - - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); - } - break; - - - default: - - Gbl_ReservedMethods++; - - /* - * Matched a reserved method name - * - * Validate the ASL-defined argument count. Allow two different legal - * arg counts. - */ - RequiredArgsCurrent = ReservedMethods[Index].NumArguments & 0x0F; - RequiredArgsOld = ReservedMethods[Index].NumArguments >> 4; - - if ((MethodInfo->NumArguments != RequiredArgsCurrent) && - (MethodInfo->NumArguments != RequiredArgsOld)) - { - sprintf (MsgBuffer, "%s requires %d", - ReservedMethods[Index].Name, - RequiredArgsCurrent); - - if (MethodInfo->NumArguments > RequiredArgsCurrent) - { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, - MsgBuffer); - } - else - { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, - MsgBuffer); - } - } - - if (MethodInfo->NumReturnNoValue && - ReservedMethods[Index].Flags & ASL_RSVD_RETURN_VALUE) - { - sprintf (MsgBuffer, "%s", ReservedMethods[Index].Name); - - AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer); - } - break; + Target[1] = 'E'; } -} - - -/******************************************************************************* - * - * FUNCTION: AnMapObjTypeToBtype - * - * PARAMETERS: Op - A parse node - * - * RETURN: A Btype - * - * DESCRIPTION: Map object to the associated "Btype" - * - ******************************************************************************/ - -static UINT32 -AnMapObjTypeToBtype ( - ACPI_PARSE_OBJECT *Op) -{ - - switch (Op->Asl.ParseOpcode) + else /* Name[1] == 'E' */ { - case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */ - return (ACPI_BTYPE_BUFFER_FIELD); - - case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */ - return (ACPI_BTYPE_BUFFER); - - case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */ - return (ACPI_BTYPE_DDB_HANDLE); - - case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */ - return (ACPI_BTYPE_DEVICE); - - case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */ - return (ACPI_BTYPE_EVENT); - - case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */ - return (ACPI_BTYPE_FIELD_UNIT); - - case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */ - return (ACPI_BTYPE_INTEGER); - - case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */ - return (ACPI_BTYPE_METHOD); - - case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */ - return (ACPI_BTYPE_MUTEX); - - case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */ - return (ACPI_BTYPE_REGION); - - case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */ - return (ACPI_BTYPE_PACKAGE); - - case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */ - return (ACPI_BTYPE_POWER); - - case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */ - return (ACPI_BTYPE_STRING); - - case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */ - return (ACPI_BTYPE_THERMAL); - - case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */ - return (ACPI_BTYPE_OBJECTS_AND_REFS); - - default: - return (0); + Target[1] = 'L'; } -} - -/******************************************************************************* - * - * FUNCTION: AnMethodAnalysisWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the analysis walk. Check methods for: - * 1) Initialized local variables - * 2) Valid arguments - * 3) Return types - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodAnalysisWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; - ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; - ACPI_PARSE_OBJECT *Next; - UINT32 RegisterNumber; - UINT32 i; - char LocalName[] = "Local0"; - char ArgName[] = "Arg0"; - ACPI_PARSE_OBJECT *ArgNode; - ACPI_PARSE_OBJECT *NextType; - ACPI_PARSE_OBJECT *NextParamType; - UINT8 ActualArgs = 0; + /* Search all peers (objects within this scope) for target match */ - - switch (Op->Asl.ParseOpcode) + NextOp = Op->Asl.Next; + while (NextOp) { - case PARSEOP_METHOD: - - TotalMethods++; - - /* Create and init method info */ - - MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); - MethodInfo->Next = WalkInfo->MethodStack; - MethodInfo->Op = Op; - - WalkInfo->MethodStack = MethodInfo; - - /* Get the name node, ignored here */ - - Next = Op->Asl.Child; - - /* Get the NumArguments node */ - - Next = Next->Asl.Next; - MethodInfo->NumArguments = (UINT8) - (((UINT8) Next->Asl.Value.Integer) & 0x07); - - /* Get the SerializeRule and SyncLevel nodes, ignored here */ - - Next = Next->Asl.Next; - Next = Next->Asl.Next; - ArgNode = Next; - - /* Get the ReturnType node */ - - Next = Next->Asl.Next; - - NextType = Next->Asl.Child; - while (NextType) - { - /* Get and map each of the ReturnTypes */ - - MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); - NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - NextType = NextType->Asl.Next; - } - - /* Get the ParameterType node */ - - Next = Next->Asl.Next; - - NextType = Next->Asl.Child; - while (NextType) - { - if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) - { - NextParamType = NextType->Asl.Child; - while (NextParamType) - { - MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); - NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - NextParamType = NextParamType->Asl.Next; - } - } - else - { - MethodInfo->ValidArgTypes[ActualArgs] = - AnMapObjTypeToBtype (NextType); - NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - ActualArgs++; - } - - NextType = NextType->Asl.Next; - } - - if ((MethodInfo->NumArguments) && - (MethodInfo->NumArguments != ActualArgs)) - { - /* error: Param list did not match number of args */ - } - - /* Allow numarguments == 0 for Function() */ - - if ((!MethodInfo->NumArguments) && (ActualArgs)) - { - MethodInfo->NumArguments = ActualArgs; - ArgNode->Asl.Value.Integer |= ActualArgs; - } - - /* - * Actual arguments are initialized at method entry. - * All other ArgX "registers" can be used as locals, so we - * track their initialization. - */ - for (i = 0; i < MethodInfo->NumArguments; i++) - { - MethodInfo->ArgInitialized[i] = TRUE; - } - break; - - - case PARSEOP_METHODCALL: - - if (MethodInfo && - (Op->Asl.Node == MethodInfo->Op->Asl.Node)) - { - AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName); - } - break; - - - case PARSEOP_LOCAL0: - case PARSEOP_LOCAL1: - case PARSEOP_LOCAL2: - case PARSEOP_LOCAL3: - case PARSEOP_LOCAL4: - case PARSEOP_LOCAL5: - case PARSEOP_LOCAL6: - case PARSEOP_LOCAL7: - - if (!MethodInfo) - { - /* - * Local was used outside a control method, or there was an error - * in the method declaration. - */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); - return (AE_ERROR); - } - - RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); - - /* - * If the local is being used as a target, mark the local - * initialized - */ - if (Op->Asl.CompileFlags & NODE_IS_TARGET) - { - MethodInfo->LocalInitialized[RegisterNumber] = TRUE; - } - - /* - * Otherwise, this is a reference, check if the local - * has been previously initialized. - * - * The only operator that accepts an uninitialized value is ObjectType() - */ - else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && - (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) - { - LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); - AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); - } - break; - - - case PARSEOP_ARG0: - case PARSEOP_ARG1: - case PARSEOP_ARG2: - case PARSEOP_ARG3: - case PARSEOP_ARG4: - case PARSEOP_ARG5: - case PARSEOP_ARG6: - - if (!MethodInfo) - { - /* - * Arg was used outside a control method, or there was an error - * in the method declaration. - */ - AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); - return (AE_ERROR); - } - - RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8; - ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30); - - /* - * If the Arg is being used as a target, mark the local - * initialized - */ - if (Op->Asl.CompileFlags & NODE_IS_TARGET) - { - MethodInfo->ArgInitialized[RegisterNumber] = TRUE; - } - - /* - * Otherwise, this is a reference, check if the Arg - * has been previously initialized. - * - * The only operator that accepts an uninitialized value is ObjectType() - */ - else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && - (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) - { - AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); - } - - /* Flag this arg if it is not a "real" argument to the method */ - - if (RegisterNumber >= MethodInfo->NumArguments) - { - AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName); - } - break; - - - case PARSEOP_RETURN: - - if (!MethodInfo) - { - /* - * Probably was an error in the method declaration, - * no additional error here - */ - ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); - return (AE_ERROR); - } - - /* Child indicates a return value */ - - if ((Op->Asl.Child) && - (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) - { - MethodInfo->NumReturnWithValue++; - } - else - { - MethodInfo->NumReturnNoValue++; - } - break; - - - case PARSEOP_BREAK: - case PARSEOP_CONTINUE: - - Next = Op->Asl.Parent; - while (Next) - { - if (Next->Asl.ParseOpcode == PARSEOP_WHILE) - { - break; - } - Next = Next->Asl.Parent; - } - - if (!Next) - { - AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL); - } - break; - - - case PARSEOP_STALL: - - /* We can range check if the argument is an integer */ - - if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && - (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) - { - AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); - } - break; - - - case PARSEOP_DEVICE: - case PARSEOP_EVENT: - case PARSEOP_MUTEX: - case PARSEOP_OPERATIONREGION: - case PARSEOP_POWERRESOURCE: - case PARSEOP_PROCESSOR: - case PARSEOP_THERMALZONE: - /* - * The first operand is a name to be created in the namespace. - * Check against the reserved list. + * We mostly care about methods, but check Name() constructs also, + * even though they will get another error for not being a method. + * All GPE names must be defined as control methods. */ - i = AnCheckForReservedName (Op, Op->Asl.NameSeg); - if (i < ACPI_VALID_RESERVED_NAME_MAX) - { - AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); - } - break; - - - case PARSEOP_NAME: - - i = AnCheckForReservedName (Op, Op->Asl.NameSeg); - if (i < ACPI_VALID_RESERVED_NAME_MAX) + if ((NextOp->Asl.ParseOpcode == PARSEOP_METHOD) || + (NextOp->Asl.ParseOpcode == PARSEOP_NAME)) { - if (ReservedMethods[i].NumArguments > 0) + if (ACPI_COMPARE_NAME (Target, NextOp->Asl.NameSeg)) { - /* - * This reserved name must be a control method because - * it must have arguments - */ - AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, - "with arguments"); - } + /* Found both _Exy and _Lxy in the same scope, error */ - /* Typechecking for _HID */ - - else if (!ACPI_STRCMP (METHOD_NAME__HID, ReservedMethods[i].Name)) - { - /* Examine the second operand to typecheck it */ - - Next = Op->Asl.Child->Asl.Next; - - if ((Next->Asl.ParseOpcode != PARSEOP_INTEGER) && - (Next->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)) - { - /* _HID must be a string or an integer */ - - AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, - "String or Integer"); - } - - if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) - { - /* - * _HID is a string, all characters must be alphanumeric. - * One of the things we want to catch here is the use of - * a leading asterisk in the string. - */ - for (i = 0; Next->Asl.Value.String[i]; i++) - { - if (!isalnum (Next->Asl.Value.String[i])) - { - AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, - Next, Next->Asl.Value.String); - break; - } - } - } + AslError (ASL_ERROR, ASL_MSG_GPE_NAME_CONFLICT, NextOp, + Name); + return; } } - break; - - default: - break; + NextOp = NextOp->Asl.Next; } - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnLastStatementIsReturn - * - * PARAMETERS: Op - A method parse node - * - * RETURN: TRUE if last statement is an ASL RETURN. False otherwise - * - * DESCRIPTION: Walk down the list of top level statements within a method - * to find the last one. Check if that last statement is in - * fact a RETURN statement. - * - ******************************************************************************/ + /* OK, no conflict found */ -static BOOLEAN -AnLastStatementIsReturn ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Next; - - - /* - * Check if last statement is a return - */ - Next = ASL_GET_CHILD_NODE (Op); - while (Next) - { - if ((!Next->Asl.Next) && - (Next->Asl.ParseOpcode == PARSEOP_RETURN)) - { - return TRUE; - } - - Next = ASL_GET_PEER_NODE (Next); - } - - return FALSE; -} - - -/******************************************************************************* - * - * FUNCTION: AnMethodAnalysisWalkEnd - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for analysis walk. Complete method - * return analysis. - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodAnalysisWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; - ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; - - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_METHOD: - case PARSEOP_RETURN: - if (!MethodInfo) - { - printf ("No method info for method! [%s]\n", Op->Asl.Namepath); - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, - "No method info for this method"); - CmCleanupAndExit (); - return (AE_AML_INTERNAL); - } - break; - - default: - break; - } - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_METHOD: - - WalkInfo->MethodStack = MethodInfo->Next; - - /* - * Check if there is no return statement at the end of the - * method AND we can actually get there -- i.e., the execution - * of the method can possibly terminate without a return statement. - */ - if ((!AnLastStatementIsReturn (Op)) && - (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT))) - { - /* - * No return statement, and execution can possibly exit - * via this path. This is equivalent to Return () - */ - MethodInfo->NumReturnNoValue++; - } - - /* - * Check for case where some return statements have a return value - * and some do not. Exit without a return statement is a return with - * no value - */ - if (MethodInfo->NumReturnNoValue && - MethodInfo->NumReturnWithValue) - { - AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, - Op->Asl.ExternalName); - } - - /* - * If there are any RETURN() statements with no value, or there is a - * control path that allows the method to exit without a return value, - * we mark the method as a method that does not return a value. This - * knowledge can be used to check method invocations that expect a - * returned value. - */ - if (MethodInfo->NumReturnNoValue) - { - if (MethodInfo->NumReturnWithValue) - { - Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL; - } - else - { - Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL; - } - } - - /* - * Check predefined method names for correct return behavior - * and correct number of arguments - */ - AnCheckForReservedMethod (Op, MethodInfo); - ACPI_FREE (MethodInfo); - break; - - - case PARSEOP_RETURN: - - /* - * The parent block does not "exit" and continue execution -- the - * method is terminated here with the Return() statement. - */ - Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - - /* Used in the "typing" pass later */ - - Op->Asl.ParentMethod = MethodInfo->Op; - - /* - * If there is a peer node after the return statement, then this - * node is unreachable code -- i.e., it won't be executed because of - * the preceeding Return() statement. - */ - if (Op->Asl.Next) - { - AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); - } - break; - - - case PARSEOP_IF: - - if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && - (Op->Asl.Next) && - (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE)) - { - /* - * This IF has a corresponding ELSE. The IF block has no exit, - * (it contains an unconditional Return) - * mark the ELSE block to remember this fact. - */ - Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT; - } - break; - - - case PARSEOP_ELSE: - - if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && - (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT)) - { - /* - * This ELSE block has no exit and the corresponding IF block - * has no exit either. Therefore, the parent node has no exit. - */ - Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - } - break; - - - default: - - if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && - (Op->Asl.Parent)) - { - /* If this node has no exit, then the parent has no exit either */ - - Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - } - break; - } - - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnMethodTypingWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the typing walk. - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodTypingWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnMethodTypingWalkEnd - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for typing walk. Complete the method - * return analysis. Check methods for: - * 1) Initialized local variables - * 2) Valid arguments - * 3) Return types - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodTypingWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - UINT32 ThisNodeBtype; - - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_METHOD: - - Op->Asl.CompileFlags |= NODE_METHOD_TYPED; - break; - - case PARSEOP_RETURN: - - if ((Op->Asl.Child) && - (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) - { - ThisNodeBtype = AnGetBtype (Op->Asl.Child); - - if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) && - (ThisNodeBtype == (ACPI_UINT32_MAX -1))) - { - /* - * The called method is untyped at this time (typically a - * forward reference). - * - * Check for a recursive method call first. - */ - if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op) - { - /* We must type the method here */ - - TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, - ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, - AnMethodTypingWalkEnd, NULL); - - ThisNodeBtype = AnGetBtype (Op->Asl.Child); - } - } - - /* Returns a value, save the value type */ - - if (Op->Asl.ParentMethod) - { - Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype; - } - } - break; - - default: - break; - } - - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnCheckMethodReturnValue - * - * PARAMETERS: Op - Parent - * OpInfo - Parent info - * ArgOp - Method invocation op - * RequiredBtypes - What caller requires - * ThisNodeBtype - What this node returns (if anything) - * - * RETURN: None - * - * DESCRIPTION: Check a method invocation for 1) A return value and if it does - * in fact return a value, 2) check the type of the return value. - * - ******************************************************************************/ - -static void -AnCheckMethodReturnValue ( - ACPI_PARSE_OBJECT *Op, - const ACPI_OPCODE_INFO *OpInfo, - ACPI_PARSE_OBJECT *ArgOp, - UINT32 RequiredBtypes, - UINT32 ThisNodeBtype) -{ - ACPI_PARSE_OBJECT *OwningOp; - ACPI_NAMESPACE_NODE *Node; - - - Node = ArgOp->Asl.Node; - - - /* Examine the parent op of this method */ - - OwningOp = Node->Op; - if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL) - { - /* Method NEVER returns a value */ - - AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName); - } - else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL) - { - /* Method SOMETIMES returns a value, SOMETIMES not */ - - AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); - } - else if (!(ThisNodeBtype & RequiredBtypes)) - { - /* Method returns a value, but the type is wrong */ - - AnFormatBtype (StringBuffer, ThisNodeBtype); - AnFormatBtype (StringBuffer2, RequiredBtypes); - - - /* - * The case where the method does not return any value at all - * was already handled in the namespace cross reference - * -- Only issue an error if the method in fact returns a value, - * but it is of the wrong type - */ - if (ThisNodeBtype != 0) - { - sprintf (MsgBuffer, - "Method returns [%s], %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); - - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AnOperandTypecheckWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the analysis walk. Check methods for: - * 1) Initialized local variables - * 2) Valid arguments - * 3) Return types - * - ******************************************************************************/ - -ACPI_STATUS -AnOperandTypecheckWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnOperandTypecheckWalkEnd - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for analysis walk. Complete method - * return analysis. - * - ******************************************************************************/ - -ACPI_STATUS -AnOperandTypecheckWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - const ACPI_OPCODE_INFO *OpInfo; - UINT32 RuntimeArgTypes; - UINT32 RuntimeArgTypes2; - UINT32 RequiredBtypes; - UINT32 ThisNodeBtype; - UINT32 CommonBtypes; - UINT32 OpcodeClass; - ACPI_PARSE_OBJECT *ArgOp; - UINT32 ArgType; - - - switch (Op->Asl.AmlOpcode) - { - case AML_RAW_DATA_BYTE: - case AML_RAW_DATA_WORD: - case AML_RAW_DATA_DWORD: - case AML_RAW_DATA_QWORD: - case AML_RAW_DATA_BUFFER: - case AML_RAW_DATA_CHAIN: - case AML_PACKAGE_LENGTH: - case AML_UNASSIGNED_OPCODE: - case AML_DEFAULT_ARG_OP: - - /* Ignore the internal (compiler-only) AML opcodes */ - - return (AE_OK); - - default: - break; - } - - OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); - if (!OpInfo) - { - return (AE_OK); - } - - ArgOp = Op->Asl.Child; - RuntimeArgTypes = OpInfo->RuntimeArgs; - OpcodeClass = OpInfo->Class; - -#ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE - /* - * Update 11/2008: In practice, we can't perform this check. A simple - * analysis is not sufficient. Also, it can cause errors when compiling - * disassembled code because of the way Switch operators are implemented - * (a While(One) loop with a named temp variable created within.) - */ - - /* - * If we are creating a named object, check if we are within a while loop - * by checking if the parent is a WHILE op. This is a simple analysis, but - * probably sufficient for many cases. - * - * Allow Scope(), Buffer(), and Package(). - */ - if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) || - ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE))) - { - if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP) - { - AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL); - } - } -#endif - - /* - * Special case for control opcodes IF/RETURN/WHILE since they - * have no runtime arg list (at this time) - */ - switch (Op->Asl.AmlOpcode) - { - case AML_IF_OP: - case AML_WHILE_OP: - case AML_RETURN_OP: - - if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) - { - /* Check for an internal method */ - - if (AnIsInternalMethod (ArgOp)) - { - return (AE_OK); - } - - /* The lone arg is a method call, check it */ - - RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER); - if (Op->Asl.AmlOpcode == AML_RETURN_OP) - { - RequiredBtypes = 0xFFFFFFFF; - } - - ThisNodeBtype = AnGetBtype (ArgOp); - if (ThisNodeBtype == ACPI_UINT32_MAX) - { - return (AE_OK); - } - AnCheckMethodReturnValue (Op, OpInfo, ArgOp, - RequiredBtypes, ThisNodeBtype); - } - return (AE_OK); - - default: - break; - } - - /* Ignore the non-executable opcodes */ - - if (RuntimeArgTypes == ARGI_INVALID_OPCODE) - { - return (AE_OK); - } - - switch (OpcodeClass) - { - case AML_CLASS_EXECUTE: - case AML_CLASS_CREATE: - case AML_CLASS_CONTROL: - case AML_CLASS_RETURN_VALUE: - - /* TBD: Change class or fix typechecking for these */ - - if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) || - (Op->Asl.AmlOpcode == AML_PACKAGE_OP) || - (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)) - { - break; - } - - /* Reverse the runtime argument list */ - - RuntimeArgTypes2 = 0; - while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes))) - { - RuntimeArgTypes2 <<= ARG_TYPE_WIDTH; - RuntimeArgTypes2 |= ArgType; - INCREMENT_ARG_LIST (RuntimeArgTypes); - } - - while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2))) - { - RequiredBtypes = AnMapArgTypeToBtype (ArgType); - - ThisNodeBtype = AnGetBtype (ArgOp); - if (ThisNodeBtype == ACPI_UINT32_MAX) - { - goto NextArgument; - } - - /* Examine the arg based on the required type of the arg */ - - switch (ArgType) - { - case ARGI_TARGETREF: - - if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) - { - /* ZERO is the placeholder for "don't store result" */ - - ThisNodeBtype = RequiredBtypes; - break; - } - - if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) - { - /* - * This is the case where an original reference to a resource - * descriptor field has been replaced by an (Integer) offset. - * These named fields are supported at compile-time only; - * the names are not passed to the interpreter (via the AML). - */ - if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || - (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL); - } - else - { - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL); - } - break; - } - - if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF)) - { - break; - } - - ThisNodeBtype = RequiredBtypes; - break; - - - case ARGI_REFERENCE: /* References */ - case ARGI_INTEGER_REF: - case ARGI_OBJECT_REF: - case ARGI_DEVICE_REF: - - switch (ArgOp->Asl.ParseOpcode) - { - case PARSEOP_LOCAL0: - case PARSEOP_LOCAL1: - case PARSEOP_LOCAL2: - case PARSEOP_LOCAL3: - case PARSEOP_LOCAL4: - case PARSEOP_LOCAL5: - case PARSEOP_LOCAL6: - case PARSEOP_LOCAL7: - - /* TBD: implement analysis of current value (type) of the local */ - /* For now, just treat any local as a typematch */ - - /*ThisNodeBtype = RequiredBtypes;*/ - break; - - case PARSEOP_ARG0: - case PARSEOP_ARG1: - case PARSEOP_ARG2: - case PARSEOP_ARG3: - case PARSEOP_ARG4: - case PARSEOP_ARG5: - case PARSEOP_ARG6: - - /* Hard to analyze argument types, sow we won't */ - /* For now, just treat any arg as a typematch */ - - /* ThisNodeBtype = RequiredBtypes; */ - break; - - case PARSEOP_DEBUG: - break; - - case PARSEOP_REFOF: - case PARSEOP_INDEX: - default: - break; - - } - break; - - case ARGI_INTEGER: - default: - break; - } - - - CommonBtypes = ThisNodeBtype & RequiredBtypes; - - if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) - { - if (AnIsInternalMethod (ArgOp)) - { - return (AE_OK); - } - - /* Check a method call for a valid return value */ - - AnCheckMethodReturnValue (Op, OpInfo, ArgOp, - RequiredBtypes, ThisNodeBtype); - } - - /* - * Now check if the actual type(s) match at least one - * bit to the required type - */ - else if (!CommonBtypes) - { - /* No match -- this is a type mismatch error */ - - AnFormatBtype (StringBuffer, ThisNodeBtype); - AnFormatBtype (StringBuffer2, RequiredBtypes); - - sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); - - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); - } - - NextArgument: - ArgOp = ArgOp->Asl.Next; - INCREMENT_ARG_LIST (RuntimeArgTypes2); - } - break; - - default: - break; - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AnIsResultUsed - * - * PARAMETERS: Op - Parent op for the operator - * - * RETURN: TRUE if result from this operation is actually consumed - * - * DESCRIPTION: Determine if the function result value from an operator is - * used. - * - ******************************************************************************/ - -BOOLEAN -AnIsResultUsed ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Parent; - - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_INCREMENT: - case PARSEOP_DECREMENT: - - /* These are standalone operators, no return value */ - - return (TRUE); - - default: - break; - } - - /* Examine parent to determine if the return value is used */ - - Parent = Op->Asl.Parent; - switch (Parent->Asl.ParseOpcode) - { - /* If/While - check if the operator is the predicate */ - - case PARSEOP_IF: - case PARSEOP_WHILE: - - /* First child is the predicate */ - - if (Parent->Asl.Child == Op) - { - return (TRUE); - } - return (FALSE); - - /* Not used if one of these is the parent */ - - case PARSEOP_METHOD: - case PARSEOP_DEFINITIONBLOCK: - case PARSEOP_ELSE: - - return (FALSE); - - default: - /* Any other type of parent means that the result is used */ - - return (TRUE); - } -} - - -/******************************************************************************* - * - * FUNCTION: AnOtherSemanticAnalysisWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the analysis walk. Checks for - * miscellaneous issues in the code. - * - ******************************************************************************/ - -ACPI_STATUS -AnOtherSemanticAnalysisWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - ACPI_PARSE_OBJECT *ArgNode; - ACPI_PARSE_OBJECT *PrevArgNode = NULL; - const ACPI_OPCODE_INFO *OpInfo; - - - OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); - - /* - * Determine if an execution class operator actually does something by - * checking if it has a target and/or the function return value is used. - * (Target is optional, so a standalone statement can actually do nothing.) - */ - if ((OpInfo->Class == AML_CLASS_EXECUTE) && - (OpInfo->Flags & AML_HAS_RETVAL) && - (!AnIsResultUsed (Op))) - { - if (OpInfo->Flags & AML_HAS_TARGET) - { - /* - * Find the target node, it is always the last child. If the traget - * is not specified in the ASL, a default node of type Zero was - * created by the parser. - */ - ArgNode = Op->Asl.Child; - while (ArgNode->Asl.Next) - { - PrevArgNode = ArgNode; - ArgNode = ArgNode->Asl.Next; - } - - /* Divide() is the only weird case, it has two targets */ - - if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) - { - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && - (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) - { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); - } - } - else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) - { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); - } - } - else - { - /* - * Has no target and the result is not used. Only a couple opcodes - * can have this combination. - */ - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_ACQUIRE: - case PARSEOP_WAIT: - case PARSEOP_LOADTABLE: - break; - - default: - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); - break; - } - } - } - - - /* - * Semantic checks for individual ASL operators - */ - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_ACQUIRE: - case PARSEOP_WAIT: - /* - * Emit a warning if the timeout parameter for these operators is not - * ACPI_WAIT_FOREVER, and the result value from the operator is not - * checked, meaning that a timeout could happen, but the code - * would not know about it. - */ - - /* First child is the namepath, 2nd child is timeout */ - - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; - - /* - * Check for the WAIT_FOREVER case - defined by the ACPI spec to be - * 0xFFFF or greater - */ - if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || - (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && - (ArgNode->Asl.Value.Integer >= (ACPI_INTEGER) ACPI_WAIT_FOREVER)) - { - break; - } - - /* - * The operation could timeout. If the return value is not used - * (indicates timeout occurred), issue a warning - */ - if (!AnIsResultUsed (Op)) - { - AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, Op->Asl.ExternalName); - } - break; - - case PARSEOP_CREATEFIELD: - /* - * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand - */ - ArgNode = Op->Asl.Child; - ArgNode = ArgNode->Asl.Next; - ArgNode = ArgNode->Asl.Next; - - if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) || - ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) && - (ArgNode->Asl.Value.Integer == 0))) - { - AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL); - } - break; - - default: - break; - } - - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnOtherSemanticAnalysisWalkEnd - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for analysis walk. Complete method - * return analysis. - * - ******************************************************************************/ - -ACPI_STATUS -AnOtherSemanticAnalysisWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; - -} - - -#ifdef ACPI_OBSOLETE_FUNCTIONS -/******************************************************************************* - * - * FUNCTION: AnMapBtypeToEtype - * - * PARAMETERS: Btype - Bitfield of ACPI types - * - * RETURN: The Etype corresponding the the Btype - * - * DESCRIPTION: Convert a bitfield type to an encoded type - * - ******************************************************************************/ - -UINT32 -AnMapBtypeToEtype ( - UINT32 Btype) -{ - UINT32 i; - UINT32 Etype; - - - if (Btype == 0) - { - return 0; - } - - Etype = 1; - for (i = 1; i < Btype; i *= 2) - { - Etype++; - } - - return (Etype); + return; } -#endif - diff --git a/sys/contrib/dev/acpica-unix/compiler/aslbtypes.c b/sys/contrib/dev/acpica-unix/compiler/aslbtypes.c new file mode 100644 index 0000000000..d17067157b --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslbtypes.c @@ -0,0 +1,597 @@ +/****************************************************************************** + * + * Module Name: aslbtypes - Support for bitfield types + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "aslcompiler.h" +#include "aslcompiler.y.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslbtypes") + +/* Local prototypes */ + +static UINT32 +AnMapEtypeToBtype ( + UINT32 Etype); + + +/******************************************************************************* + * + * FUNCTION: AnMapArgTypeToBtype + * + * PARAMETERS: ArgType - The ARGI required type(s) for this + * argument, from the opcode info table + * + * RETURN: The corresponding Bit-encoded types + * + * DESCRIPTION: Convert an encoded ARGI required argument type code into a + * bitfield type code. Implements the implicit source conversion + * rules. + * + ******************************************************************************/ + +UINT32 +AnMapArgTypeToBtype ( + UINT32 ArgType) +{ + + switch (ArgType) + { + + /* Simple types */ + + case ARGI_ANYTYPE: + return (ACPI_BTYPE_OBJECTS_AND_REFS); + + case ARGI_PACKAGE: + return (ACPI_BTYPE_PACKAGE); + + case ARGI_EVENT: + return (ACPI_BTYPE_EVENT); + + case ARGI_MUTEX: + return (ACPI_BTYPE_MUTEX); + + case ARGI_DDBHANDLE: + /* + * DDBHandleObject := SuperName + * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload + */ + return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE); + + /* Interchangeable types */ + /* + * Source conversion rules: + * Integer, String, and Buffer are all interchangeable + */ + case ARGI_INTEGER: + case ARGI_STRING: + case ARGI_BUFFER: + case ARGI_BUFFER_OR_STRING: + case ARGI_COMPUTEDATA: + return (ACPI_BTYPE_COMPUTE_DATA); + + /* References */ + + case ARGI_INTEGER_REF: + return (ACPI_BTYPE_INTEGER); + + case ARGI_OBJECT_REF: + return (ACPI_BTYPE_ALL_OBJECTS); + + case ARGI_DEVICE_REF: + return (ACPI_BTYPE_DEVICE_OBJECTS); + + case ARGI_REFERENCE: + return (ACPI_BTYPE_REFERENCE); + + case ARGI_TARGETREF: + case ARGI_FIXED_TARGET: + case ARGI_SIMPLE_TARGET: + return (ACPI_BTYPE_OBJECTS_AND_REFS); + + /* Complex types */ + + case ARGI_DATAOBJECT: + + /* + * Buffer, string, package or reference to a Op - + * Used only by SizeOf operator + */ + return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + + case ARGI_COMPLEXOBJ: + + /* Buffer, String, or package */ + + return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); + + case ARGI_REF_OR_STRING: + return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); + + case ARGI_REGION_OR_BUFFER: + + /* Used by Load() only. Allow buffers in addition to regions/fields */ + + return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); + + case ARGI_DATAREFOBJ: + return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + + default: + break; + } + + return (ACPI_BTYPE_OBJECTS_AND_REFS); +} + + +/******************************************************************************* + * + * FUNCTION: AnMapEtypeToBtype + * + * PARAMETERS: Etype - Encoded ACPI Type + * + * RETURN: Btype corresponding to the Etype + * + * DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the + * operand conversion rules. In other words, returns the type(s) + * this Etype is implicitly converted to during interpretation. + * + ******************************************************************************/ + +static UINT32 +AnMapEtypeToBtype ( + UINT32 Etype) +{ + + + if (Etype == ACPI_TYPE_ANY) + { + return (ACPI_BTYPE_OBJECTS_AND_REFS); + } + + /* Try the standard ACPI data types */ + + if (Etype <= ACPI_TYPE_EXTERNAL_MAX) + { + /* + * This switch statement implements the allowed operand conversion + * rules as per the "ASL Data Types" section of the ACPI + * specification. + */ + switch (Etype) + { + case ACPI_TYPE_INTEGER: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE); + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + return (ACPI_BTYPE_COMPUTE_DATA); + + case ACPI_TYPE_PACKAGE: + return (ACPI_BTYPE_PACKAGE); + + case ACPI_TYPE_FIELD_UNIT: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); + + case ACPI_TYPE_BUFFER_FIELD: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD); + + case ACPI_TYPE_DDB_HANDLE: + return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); + + case ACPI_BTYPE_DEBUG_OBJECT: + + /* Cannot be used as a source operand */ + + return (0); + + default: + return (1 << (Etype - 1)); + } + } + + /* Try the internal data types */ + + switch (Etype) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* Named fields can be either Integer/Buffer/String */ + + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); + + case ACPI_TYPE_LOCAL_ALIAS: + + return (ACPI_BTYPE_INTEGER); + + + case ACPI_TYPE_LOCAL_RESOURCE: + case ACPI_TYPE_LOCAL_RESOURCE_FIELD: + + return (ACPI_BTYPE_REFERENCE); + + default: + printf ("Unhandled encoded type: %X\n", Etype); + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AnFormatBtype + * + * PARAMETERS: Btype - Bitfield of ACPI types + * Buffer - Where to put the ascii string + * + * RETURN: None. + * + * DESCRIPTION: Convert a Btype to a string of ACPI types + * + ******************************************************************************/ + +void +AnFormatBtype ( + char *Buffer, + UINT32 Btype) +{ + UINT32 Type; + BOOLEAN First = TRUE; + + + *Buffer = 0; + + if (Btype == 0) + { + strcat (Buffer, "NoReturnValue"); + return; + } + + for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++) + { + if (Btype & 0x00000001) + { + if (!First) + { + strcat (Buffer, "|"); + } + First = FALSE; + strcat (Buffer, AcpiUtGetTypeName (Type)); + } + Btype >>= 1; + } + + if (Btype & 0x00000001) + { + if (!First) + { + strcat (Buffer, "|"); + } + First = FALSE; + strcat (Buffer, "Reference"); + } + + Btype >>= 1; + if (Btype & 0x00000001) + { + if (!First) + { + strcat (Buffer, "|"); + } + First = FALSE; + strcat (Buffer, "Resource"); + } +} + + +/******************************************************************************* + * + * FUNCTION: AnGetBtype + * + * PARAMETERS: Op - Parse node whose type will be returned. + * + * RETURN: The Btype associated with the Op. + * + * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node. + * Handles the case where the node is a name or method call and + * the actual type must be obtained from the namespace node. + * + ******************************************************************************/ + +UINT32 +AnGetBtype ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *ReferencedNode; + UINT32 ThisNodeBtype = 0; + + + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || + (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || + (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) + { + Node = Op->Asl.Node; + if (!Node) + { + DbgPrint (ASL_DEBUG_OUTPUT, + "No attached Nsnode: [%s] at line %u name [%s], ignoring typecheck\n", + Op->Asl.ParseOpName, Op->Asl.LineNumber, + Op->Asl.ExternalName); + return (ACPI_UINT32_MAX); + } + + ThisNodeBtype = AnMapEtypeToBtype (Node->Type); + if (!ThisNodeBtype) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "could not map type"); + } + + /* + * Since it was a named reference, enable the + * reference bit also + */ + ThisNodeBtype |= ACPI_BTYPE_REFERENCE; + + if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) + { + ReferencedNode = Node->Op; + if (!ReferencedNode) + { + /* Check for an internal method */ + + if (AnIsInternalMethod (Op)) + { + return (AnGetInternalMethodReturnType (Op)); + } + + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "null Op pointer"); + return (ACPI_UINT32_MAX); + } + + if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED) + { + ThisNodeBtype = ReferencedNode->Asl.AcpiBtype; + } + else + { + return (ACPI_UINT32_MAX -1); + } + } + } + else + { + ThisNodeBtype = Op->Asl.AcpiBtype; + } + + return (ThisNodeBtype); +} + + +/******************************************************************************* + * + * FUNCTION: AnMapObjTypeToBtype + * + * PARAMETERS: Op - A parse node + * + * RETURN: A Btype + * + * DESCRIPTION: Map object to the associated "Btype" + * + ******************************************************************************/ + +UINT32 +AnMapObjTypeToBtype ( + ACPI_PARSE_OBJECT *Op) +{ + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */ + return (ACPI_BTYPE_BUFFER_FIELD); + + case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */ + return (ACPI_BTYPE_BUFFER); + + case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */ + return (ACPI_BTYPE_DDB_HANDLE); + + case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */ + return (ACPI_BTYPE_DEVICE); + + case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */ + return (ACPI_BTYPE_EVENT); + + case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */ + return (ACPI_BTYPE_FIELD_UNIT); + + case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */ + return (ACPI_BTYPE_INTEGER); + + case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */ + return (ACPI_BTYPE_METHOD); + + case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */ + return (ACPI_BTYPE_MUTEX); + + case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */ + return (ACPI_BTYPE_REGION); + + case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */ + return (ACPI_BTYPE_PACKAGE); + + case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */ + return (ACPI_BTYPE_POWER); + + case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */ + return (ACPI_BTYPE_STRING); + + case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */ + return (ACPI_BTYPE_THERMAL); + + case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */ + return (ACPI_BTYPE_OBJECTS_AND_REFS); + + default: + return (0); + } +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AnMapBtypeToEtype + * + * PARAMETERS: Btype - Bitfield of ACPI types + * + * RETURN: The Etype corresponding the the Btype + * + * DESCRIPTION: Convert a bitfield type to an encoded type + * + ******************************************************************************/ + +UINT32 +AnMapBtypeToEtype ( + UINT32 Btype) +{ + UINT32 i; + UINT32 Etype; + + + if (Btype == 0) + { + return (0); + } + + Etype = 1; + for (i = 1; i < Btype; i *= 2) + { + Etype++; + } + + return (Etype); +} +#endif diff --git a/sys/contrib/dev/acpica-unix/compiler/aslcodegen.c b/sys/contrib/dev/acpica-unix/compiler/aslcodegen.c index af3f292e3f..715e537935 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslcodegen.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -513,11 +513,11 @@ CgWriteTableHeader ( /* Compiler ID */ - strncpy (TableHeader.AslCompilerId, CompilerCreatorId, 4); + strncpy (TableHeader.AslCompilerId, ASL_CREATOR_ID, 4); /* Compiler version */ - TableHeader.AslCompilerRevision = CompilerCreatorRevision; + TableHeader.AslCompilerRevision = ASL_REVISION; /* Table length. Checksum zero for now, will rewrite later */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslcompile.c b/sys/contrib/dev/acpica-unix/compiler/aslcompile.c index 07de1fe63c..5becc6e285 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslcompile.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,9 +114,11 @@ * *****************************************************************************/ +#include "aslcompiler.h" + #include #include -#include "aslcompiler.h" +#include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslcompile") @@ -127,16 +129,12 @@ static void CmFlushSourceCode ( void); -static ACPI_STATUS -FlCheckForAscii ( - ASL_FILE_INFO *FileInfo); - -void +static void FlConsumeAnsiComment ( ASL_FILE_INFO *FileInfo, ASL_FILE_STATUS *Status); -void +static void FlConsumeNewComment ( ASL_FILE_INFO *FileInfo, ASL_FILE_STATUS *Status); @@ -159,6 +157,7 @@ AslCompilerSignon ( UINT32 FileId) { char *Prefix = ""; + char *UtilityName; /* Set line prefix depending on the destination file type */ @@ -177,7 +176,8 @@ AslCompilerSignon ( { Prefix = "; "; } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) { FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); Prefix = " * "; @@ -195,36 +195,21 @@ AslCompilerSignon ( break; } - /* - * Compiler signon with copyright - */ - FlPrintFile (FileId, - "%s\n%s%s\n%s", - Prefix, - Prefix, IntelAcpiCA, - Prefix); - /* Running compiler or disassembler? */ if (Gbl_DisasmFlag) { - FlPrintFile (FileId, - "%s", DisassemblerId); + UtilityName = AML_DISASSEMBLER_NAME; } else { - FlPrintFile (FileId, - "%s", CompilerId); + UtilityName = ASL_COMPILER_NAME; } - /* Version, build date, copyright, compliance */ + /* Compiler signon with copyright */ - FlPrintFile (FileId, - " version %X [%s]\n%s%s\n%s%s\n%s\n", - (UINT32) ACPI_CA_VERSION, __DATE__, - Prefix, CompilerCopyright, - Prefix, CompilerCompliance, - Prefix); + FlPrintFile (FileId, "%s\n", Prefix); + FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); } @@ -265,7 +250,8 @@ AslCompilerFileHeader ( { Prefix = "; "; } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) { Prefix = " * "; } @@ -347,7 +333,7 @@ CmFlushSourceCode ( * ******************************************************************************/ -void +static void FlConsumeAnsiComment ( ASL_FILE_INFO *FileInfo, ASL_FILE_STATUS *Status) @@ -391,7 +377,7 @@ FlConsumeAnsiComment ( } -void +static void FlConsumeNewComment ( ASL_FILE_INFO *FileInfo, ASL_FILE_STATUS *Status) @@ -431,7 +417,7 @@ FlConsumeNewComment ( * ******************************************************************************/ -static ACPI_STATUS +ACPI_STATUS FlCheckForAscii ( ASL_FILE_INFO *FileInfo) { @@ -541,31 +527,6 @@ CmDoCompile ( FullCompile = UtBeginEvent ("*** Total Compile time ***"); Event = UtBeginEvent ("Open input and output files"); - - /* Open the required input and output files */ - - Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; - } - - /* Check for 100% ASCII source file (comments are ignored) */ - - Status = FlCheckForAscii (&Gbl_Files[ASL_FILE_INPUT]); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; - } - - Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; - } UtEndEvent (Event); /* Build the parse tree */ @@ -711,27 +672,25 @@ CmDoCompile ( Event = UtBeginEvent ("Determine object types returned by methods"); DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, - AnMethodTypingWalkBegin, - AnMethodTypingWalkEnd, NULL); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, AnMethodTypingWalkEnd, NULL); UtEndEvent (Event); /* Semantic error checking part three - operand type checking */ Event = UtBeginEvent ("Analyze AML operand types"); DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, - AnOperandTypecheckWalkBegin, - AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); UtEndEvent (Event); /* Semantic error checking part four - other miscellaneous checks */ Event = UtBeginEvent ("Miscellaneous analysis"); DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, AnOtherSemanticAnalysisWalkBegin, - AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo); + NULL, &AnalysisWalkInfo); UtEndEvent (Event); /* Calculate all AML package lengths */ @@ -886,15 +845,28 @@ CmCleanupAndExit ( if (Gbl_NsLookupCount) { - DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n"); - DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", + DbgPrint (ASL_DEBUG_OUTPUT, + "\n\nMiscellaneous compile statistics\n\n"); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%32s : %u\n", "Total Namespace searches", Gbl_NsLookupCount); - DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d usec\n", "Time per search", - ((UINT32) (AslGbl_Events[AslGbl_NamespaceEvent].EndTime - - AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / - 10) / Gbl_NsLookupCount); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%32s : %u usec\n", "Time per search", ((UINT32) + (AslGbl_Events[AslGbl_NamespaceEvent].EndTime - + AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) / + Gbl_NsLookupCount); } + if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) + { + printf ("\nMaximum error count (%u) exceeded\n", + ASL_MAX_ERROR_COUNT); + } + + UtDisplaySummary (ASL_FILE_STDOUT); + /* Close all open files */ for (i = 2; i < ASL_MAX_FILE_TYPE; i++) @@ -902,27 +874,42 @@ CmCleanupAndExit ( FlCloseFile (i); } - /* - * TBD: SourceOutput should be .TMP, then rename if we want to keep it? - */ - if (!Gbl_SourceOutputFlag) - { - remove (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); - } - /* Delete AML file if there are errors */ - if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors)) + if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) { - remove (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename); + if (remove (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename)) + { + printf ("%s: ", + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename); + perror ("Could not delete AML file"); + } } - if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) + /* + * Delete intermediate ("combined") source file (if -ls flag not set) + * This file is created during normal ASL/AML compiles. It is not + * created by the data table compiler. + * + * If the -ls flag is set, then the .SRC file should not be deleted. + * In this case, Gbl_SourceOutputFlag is set to TRUE. + * + * Note: Handles are cleared by FlCloseFile above, so we look at the + * filename instead, to determine if the .SRC file was actually + * created. + * + * TBD: SourceOutput should be .TMP, then rename if we want to keep it? + */ + if (!Gbl_SourceOutputFlag && Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename) { - printf ("\nMaximum error count (%d) exceeded\n", ASL_MAX_ERROR_COUNT); + if (remove (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename)) + { + printf ("%s: ", + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); + perror ("Could not delete SRC file"); + } } - - UtDisplaySummary (ASL_FILE_STDOUT); } diff --git a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.h b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.h index 54162a7c5e..a639b4f7cc 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +118,10 @@ #ifndef __ASLCOMPILER_H #define __ASLCOMPILER_H +#include "acpi.h" +#include "accommon.h" +#include "amlresrc.h" +#include "acdebug.h" /* Microsoft-specific */ @@ -137,16 +141,11 @@ #include #include - -#include "acpi.h" -#include "accommon.h" -#include "amlresrc.h" -#include "acdebug.h" - /* Compiler headers */ #include "asldefine.h" #include "asltypes.h" +#include "aslmessages.h" #include "aslglobal.h" @@ -189,11 +188,20 @@ AslPushInputFileStack ( char *Filename); /* - * aslstartup - called from main + * aslstartup - entered from main() */ +void +AslInitializeGlobals ( + void); + +typedef +ACPI_STATUS (*ASL_PATHNAME_CALLBACK) ( + char *); + ACPI_STATUS AslDoOnePathname ( - char *Pathname); + char *Pathname, + ASL_PATHNAME_CALLBACK Callback); ACPI_STATUS AslDoOneFile ( @@ -222,9 +230,13 @@ void CmCleanupAndExit ( void); +ACPI_STATUS +FlCheckForAscii ( + ASL_FILE_INFO *FileInfo); + /* - * aslanalyze - semantic analysis + * aslwalks - semantic analysis and parse tree walks */ ACPI_STATUS AnOtherSemanticAnalysisWalkBegin ( @@ -238,12 +250,6 @@ AnOtherSemanticAnalysisWalkEnd ( UINT32 Level, void *Context); -ACPI_STATUS -AnOperandTypecheckWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - ACPI_STATUS AnOperandTypecheckWalkEnd ( ACPI_PARSE_OBJECT *Op, @@ -263,16 +269,73 @@ AnMethodAnalysisWalkEnd ( void *Context); ACPI_STATUS -AnMethodTypingWalkBegin ( +AnMethodTypingWalkEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); -ACPI_STATUS -AnMethodTypingWalkEnd ( + +/* + * aslbtypes - bitfield data types + */ +UINT32 +AnMapObjTypeToBtype ( + ACPI_PARSE_OBJECT *Op); + +UINT32 +AnMapArgTypeToBtype ( + UINT32 ArgType); + +UINT32 +AnGetBtype ( + ACPI_PARSE_OBJECT *Op); + +void +AnFormatBtype ( + char *Buffer, + UINT32 Btype); + + +/* + * aslanalyze - Support functions for parse tree walks + */ +void +AnCheckId ( ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); + ACPI_NAME Type); + +/* Values for Type argument above */ + +#define ASL_TYPE_HID 0 +#define ASL_TYPE_CID 1 + +BOOLEAN +AnIsInternalMethod ( + ACPI_PARSE_OBJECT *Op); + +UINT32 +AnGetInternalMethodReturnType ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AnLastStatementIsReturn ( + ACPI_PARSE_OBJECT *Op); + +void +AnCheckMethodReturnValue ( + ACPI_PARSE_OBJECT *Op, + const ACPI_OPCODE_INFO *OpInfo, + ACPI_PARSE_OBJECT *ArgOp, + UINT32 RequiredBtypes, + UINT32 ThisNodeBtype); + +BOOLEAN +AnIsResultUsed ( + ACPI_PARSE_OBJECT *Op); + +void +ApCheckForGpeNameConflict ( + ACPI_PARSE_OBJECT *Op); /* @@ -425,6 +488,16 @@ CgGenerateAmlOutput ( void); +/* + * aslfile + */ +void +FlOpenFile ( + UINT32 FileId, + char *Filename, + char *Mode); + + /* * asllength - calculate/adjust AML package lengths */ @@ -452,8 +525,32 @@ ACPI_OBJECT_TYPE AslMapNamedOpcodeToDataType ( UINT16 Opcode); + +/* + * aslpredef - ACPI predefined names support + */ void -MpDisplayReservedNames ( +ApCheckForPredefinedMethod ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo); + +void +ApCheckPredefinedReturnValue ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo); + +UINT32 +ApCheckForPredefinedName ( + ACPI_PARSE_OBJECT *Op, + char *Name); + +void +ApCheckForPredefinedObject ( + ACPI_PARSE_OBJECT *Op, + char *Name); + +void +ApDisplayReservedNames ( void); @@ -511,7 +608,11 @@ TrCreateLeafNode ( ACPI_PARSE_OBJECT * TrCreateValuedLeafNode ( UINT32 ParseOpcode, - ACPI_INTEGER Value); + UINT64 Value); + +ACPI_PARSE_OBJECT * +TrCreateConstantLeafNode ( + UINT32 ParseOpcode); ACPI_PARSE_OBJECT * TrLinkChildren ( @@ -555,6 +656,10 @@ void AslAbort ( void); +void +FlAddIncludeDirectory ( + char *Dir); + void FlOpenIncludeFile ( ACPI_PARSE_OBJECT *Op); @@ -564,6 +669,10 @@ FlFileError ( UINT32 FileId, UINT8 ErrorId); +UINT32 +FlGetFileSize ( + UINT32 FileId); + ACPI_STATUS FlReadFile ( UINT32 FileId, @@ -631,6 +740,10 @@ ACPI_STATUS LsDisplayNamespace ( void); +void +LsSetupNsList ( + void *Handle); + /* * aslutils - common compiler utilites @@ -647,6 +760,10 @@ DbgPrint ( #define ASL_PARSE_OUTPUT 1 #define ASL_TREE_OUTPUT 2 +void +UtDisplaySupportedTables ( + void); + void UtDisplayConstantOpcodes ( void); @@ -714,14 +831,60 @@ UtCheckIntegerRange ( UINT32 LowValue, UINT32 HighValue); -ACPI_INTEGER +UINT64 UtDoConstant ( char *String); +/* + * asluuid - UUID support + */ +ACPI_STATUS +AuValidateUuid ( + char *InString); + +ACPI_STATUS +AuConvertStringToUuid ( + char *InString, + char *UuIdBuffer); + +ACPI_STATUS +AuConvertUuidToString ( + char *UuIdBuffer, + char *OutString); /* * aslresource - Resource template generation utilities */ +void +RsSmallAddressCheck ( + UINT8 Type, + UINT32 Minimum, + UINT32 Maximum, + UINT32 Length, + UINT32 Alignment, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *AlignOp, + ACPI_PARSE_OBJECT *Op); + +void +RsLargeAddressCheck ( + UINT64 Minimum, + UINT64 Maximum, + UINT64 Length, + UINT64 Granularity, + UINT8 Flags, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *GranOp, + ACPI_PARSE_OBJECT *Op); + +UINT16 +RsGetStringDataLength ( + ACPI_PARSE_OBJECT *InitializerOp); + ASL_RESOURCE_NODE * RsAllocateResourceNode ( UINT32 Size); @@ -777,7 +940,7 @@ RsDoResourceTemplate ( /* - * aslrestype1 - generate Small descriptors + * aslrestype1 - Miscellaneous Small descriptors */ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( @@ -785,68 +948,72 @@ RsDoEndTagDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoDmaDescriptor ( +RsDoEndDependentDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoEndDependentDescriptor ( +RsDoMemory24Descriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoFixedIoDescriptor ( +RsDoMemory32Descriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoIoDescriptor ( +RsDoMemory32FixedDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoIrqDescriptor ( +RsDoStartDependentDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoIrqNoFlagsDescriptor ( +RsDoStartDependentNoPriDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoMemory24Descriptor ( +RsDoVendorSmallDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype1i - I/O-related Small descriptors + */ ASL_RESOURCE_NODE * -RsDoMemory32Descriptor ( +RsDoDmaDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoMemory32FixedDescriptor ( +RsDoFixedIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoStartDependentDescriptor ( +RsDoIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoStartDependentNoPriDescriptor ( +RsDoIrqDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoVendorSmallDescriptor ( +RsDoIrqNoFlagsDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); /* - * aslrestype2 - generate Large descriptors + * aslrestype2 - Large resource descriptors */ ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( @@ -854,6 +1021,20 @@ RsDoInterruptDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * +RsDoVendorLargeDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoGeneralRegisterDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + + +/* + * aslrestype2d - DWord address descriptors + */ +ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); @@ -868,6 +1049,10 @@ RsDoDwordSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2e - Extended address descriptors + */ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -883,6 +1068,10 @@ RsDoExtendedSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2q - QWord address descriptors + */ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -898,6 +1087,10 @@ RsDoQwordSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2w - Word address descriptors + */ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -913,15 +1106,16 @@ RsDoWordBusNumberDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); -ASL_RESOURCE_NODE * -RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); +/* + * Entry to data table compiler subsystem + */ +ACPI_STATUS +DtDoCompile( + void); -ASL_RESOURCE_NODE * -RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); +ACPI_STATUS +DtCreateTemplates ( + char *Signature); #endif /* __ASLCOMPILER_H */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.l b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.l index 3a52348c49..4215ee3e6b 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.l @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,11 @@ * *****************************************************************************/ +#include "aslcompiler.h" +#include "aslcompiler.y.h" #include #include -#include "aslcompiler.h" -#include "aslcompiler.y.h" YYSTYPE AslCompilerlval; /* @@ -386,6 +386,7 @@ NamePathTail [.]{NameSeg} "SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); } "SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); } "PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); } +"IPMI" { count (0); return (PARSEOP_REGIONSPACE_IPMI); } "FFixedHW" { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); } @@ -463,6 +464,9 @@ NamePathTail [.]{NameSeg} "AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); } "AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); } +"__DATE__" { count (0); return (PARSEOP___DATE__); } +"__FILE__" { count (0); return (PARSEOP___FILE__); } +"__LINE__" { count (0); return (PARSEOP___LINE__); } "{" { count (0); return('{'); } "}" { count (0); return('}'); } @@ -724,7 +728,7 @@ InsertLineBuffer ( * Warning if we have split a long source line. * */ - sprintf (MsgBuffer, "Max %d", ASL_LINE_BUFFER_SIZE); + sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE); AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, Gbl_CurrentColumn, diff --git a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.y b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.y index 053574f21b..d64642d24b 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica-unix/compiler/aslcompiler.y @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -400,6 +400,7 @@ AslLocalAllocate (unsigned int Size); %token PARSEOP_REGIONSPACE_CMOS %token PARSEOP_REGIONSPACE_EC %token PARSEOP_REGIONSPACE_IO +%token PARSEOP_REGIONSPACE_IPMI %token PARSEOP_REGIONSPACE_MEM %token PARSEOP_REGIONSPACE_PCI %token PARSEOP_REGIONSPACE_PCIBAR @@ -463,6 +464,13 @@ AslLocalAllocate (unsigned int Size); %token PARSEOP_XOR %token PARSEOP_ZERO +/* + * Special functions. These should probably stay at the end of this + * table. + */ +%token PARSEOP___DATE__ +%token PARSEOP___FILE__ +%token PARSEOP___LINE__ /* * Production names @@ -766,7 +774,6 @@ AslLocalAllocate (unsigned int Size); %type OptionalReference %type OptionalAccessSize - %type TermArgItem %type NameStringItem @@ -2175,6 +2182,7 @@ RegionSpaceKeyword | PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);} | PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);} | PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);} + | PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);} ; AddressSpaceKeyword @@ -2386,7 +2394,10 @@ QWordConstExpr ConstExprTerm : PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);} | PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);} - | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_INTEGER_MAX);} + | PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);} + | PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);} + | PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);} + | PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);} ; /* OptionalCount must appear before ByteList or an incorrect reduction will result */ @@ -3140,7 +3151,6 @@ NameStringItem | ',' error {$$ = AslDoError (); yyclearin;} ; - %% @@ -3162,7 +3172,7 @@ AslLocalAllocate (unsigned int Size) void *Mem; - DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %d\n\n", Size); + DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); Mem = ACPI_ALLOCATE_ZEROED (Size); if (!Mem) diff --git a/sys/contrib/dev/acpica-unix/compiler/asldefine.h b/sys/contrib/dev/acpica-unix/compiler/asldefine.h index c66040bbe4..f562f182b3 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asldefine.h +++ b/sys/contrib/dev/acpica-unix/compiler/asldefine.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -122,15 +122,13 @@ /* * Compiler versions and names */ -#define CompilerCreatorRevision ACPI_CA_VERSION +#define ASL_REVISION ACPI_CA_VERSION +#define ASL_COMPILER_NAME "ASL Optimizing Compiler" +#define AML_DISASSEMBLER_NAME "AML Disassembler" +#define ASL_INVOCATION_NAME "iasl" +#define ASL_CREATOR_ID "INTL" -#define IntelAcpiCA "Intel ACPI Component Architecture" -#define CompilerId "ASL Optimizing Compiler" -#define DisassemblerId "AML Disassembler" -#define CompilerCopyright "Copyright (C) 2000 - 2009 Intel Corporation" -#define CompilerCompliance "Supports ACPI Specification Revision 3.0a" -#define CompilerName "iasl" -#define CompilerCreatorId "INTL" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 4.0a" /* Configuration constants */ @@ -182,6 +180,14 @@ #define FILE_SUFFIX_DISASSEMBLY "dsl" #define FILE_SUFFIX_ASM_INCLUDE "inc" #define FILE_SUFFIX_C_INCLUDE "h" +#define FILE_SUFFIX_ASL_CODE "asl" + + +/* Types for input files */ + +#define ASL_INPUT_TYPE_BINARY 0 +#define ASL_INPUT_TYPE_ASCII_ASL 1 +#define ASL_INPUT_TYPE_ASCII_DATA 2 /* Misc */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslerror.c b/sys/contrib/dev/acpica-unix/compiler/aslerror.c index 87300b1529..a3bd25e74a 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslerror.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslerror.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -169,13 +169,7 @@ AeAddToErrorLog ( ASL_ERROR_MSG *Prev; - if (!Gbl_ErrorLog) - { - Gbl_ErrorLog = Enode; - return; - } - - /* List is sorted according to line number */ + /* If Gbl_ErrorLog is null, this is the first error node */ if (!Gbl_ErrorLog) { @@ -183,8 +177,10 @@ AeAddToErrorLog ( return; } - /* Walk error list until we find a line number greater than ours */ - + /* + * Walk error list until we find a line number greater than ours. + * List is sorted according to line number. + */ Prev = NULL; Next = Gbl_ErrorLog; @@ -245,6 +241,8 @@ AePrintException ( UINT32 ErrorColumn; FILE *OutputFile; FILE *SourceFile; + long FileSize; + BOOLEAN PrematureEOF = FALSE; if (Gbl_NoErrors) @@ -284,7 +282,27 @@ AePrintException ( /* Get the file handles */ OutputFile = Gbl_Files[FileId].Handle; + + /* Use the merged header/source file if present, otherwise use input file */ + SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; + if (!SourceFile) + { + SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle; + } + + if (SourceFile) + { + /* Determine if the error occurred at source file EOF */ + + fseek (SourceFile, 0, SEEK_END); + FileSize = ftell (SourceFile); + + if ((long) Enode->LogicalByteOffset >= FileSize) + { + PrematureEOF = TRUE; + } + } if (Header) { @@ -301,36 +319,45 @@ AePrintException ( if (Enode->LineNumber) { - fprintf (OutputFile, "%6u: ", Enode->LineNumber); + fprintf (OutputFile, " %6u: ", Enode->LineNumber); /* - * Seek to the offset in the combined source file, read the source - * line, and write it to the output. + * If not at EOF, get the corresponding source code line and + * display it. Don't attempt this if we have a premature EOF + * condition. */ - Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, - (int) SEEK_SET); - if (Actual) - { - fprintf (OutputFile, - "[*** iASL: Seek error on source code temp file %s ***]", - Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); - } - else + if (!PrematureEOF) { - RActual = fread (&SourceByte, 1, 1, SourceFile); - if (!RActual) + /* + * Seek to the offset in the combined source file, read + * the source line, and write it to the output. + */ + Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, + (int) SEEK_SET); + if (Actual) { fprintf (OutputFile, - "[*** iASL: Read error on source code temp file %s ***]", + "[*** iASL: Seek error on source code temp file %s ***]", Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); } - - else while (RActual && SourceByte && (SourceByte != '\n')) + else { - fwrite (&SourceByte, 1, 1, OutputFile); RActual = fread (&SourceByte, 1, 1, SourceFile); + if (!RActual) + { + fprintf (OutputFile, + "[*** iASL: Read error on source code temp file %s ***]", + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); + } + + else while (RActual && SourceByte && (SourceByte != '\n')) + { + fwrite (&SourceByte, 1, 1, OutputFile); + RActual = fread (&SourceByte, 1, 1, SourceFile); + } } } + fprintf (OutputFile, "\n"); } } @@ -355,7 +382,7 @@ AePrintException ( { /* Decode the message ID */ - fprintf (OutputFile, "%s %4.4d -", + fprintf (OutputFile, "%s %4.4d - ", AslErrorLevel[Enode->Level], Enode->MessageId + ((Enode->Level+1) * 1000)); @@ -373,7 +400,7 @@ AePrintException ( ExtraMessage = NULL; } - if (Gbl_VerboseErrors) + if (Gbl_VerboseErrors && !PrematureEOF) { SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; @@ -403,6 +430,11 @@ AePrintException ( fprintf (OutputFile, " (%s)", ExtraMessage); } + if (PrematureEOF) + { + fprintf (OutputFile, " and premature End-Of-File"); + } + fprintf (OutputFile, "\n"); if (Gbl_VerboseErrors) { @@ -529,12 +561,13 @@ AslCommonError ( Gbl_ExceptionCount[Level]++; if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) { - printf ("\nMaximum error count (%d) exceeded\n", ASL_MAX_ERROR_COUNT); + printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; CmDoOutputFiles (); CmCleanupAndExit (); + exit(1); } return; diff --git a/sys/contrib/dev/acpica-unix/compiler/aslfiles.c b/sys/contrib/dev/acpica-unix/compiler/aslfiles.c index cb38e900b0..8a1fcd0eff 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslfiles.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -122,16 +122,11 @@ /* Local prototypes */ -static void -FlOpenFile ( - UINT32 FileId, - char *Filename, - char *Mode); - static FILE * -FlOpenLocalFile ( - char *LocalName, - char *Mode); +FlOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename); + #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS @@ -170,45 +165,6 @@ AslAbort ( } -/******************************************************************************* - * - * FUNCTION: FlOpenLocalFile - * - * PARAMETERS: LocalName - Single filename (not a pathname) - * Mode - Open mode for fopen - * - * RETURN: File descriptor - * - * DESCRIPTION: Build a complete pathname for the input filename and open - * the file. - * - ******************************************************************************/ - -static FILE * -FlOpenLocalFile ( - char *LocalName, - char *Mode) -{ - - StringBuffer[0] = 0; - - /* Check for an absolute pathname */ - - if ((LocalName[0] != '/') && /* Forward slash */ - (LocalName[0] != '\\') && /* backslash (Win) */ - (LocalName[1] != ':')) /* Device name (Win) */ - { - /* The include file path is relative, prepend the directory path */ - - strcat (StringBuffer, Gbl_DirectoryPath); - } - strcat (StringBuffer, LocalName); - - DbgPrint (ASL_PARSE_OUTPUT, "FlOpenLocalFile: %s\n", StringBuffer); - return (fopen (StringBuffer, (const char *) Mode)); -} - - /******************************************************************************* * * FUNCTION: FlFileError @@ -250,7 +206,7 @@ FlFileError ( * ******************************************************************************/ -static void +void FlOpenFile ( UINT32 FileId, char *Filename, @@ -272,6 +228,36 @@ FlOpenFile ( } +/******************************************************************************* + * + * FUNCTION: FlGetFileSize + * + * PARAMETERS: FileId - Index into file info array + * + * RETURN: File Size + * + * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. + * + ******************************************************************************/ + +UINT32 +FlGetFileSize ( + UINT32 FileId) +{ + FILE *fp; + UINT32 FileSize; + + + fp = Gbl_Files[FileId].Handle; + + fseek (fp, 0, SEEK_END); + FileSize = (UINT32) ftell (fp); + fseek (fp, 0, SEEK_SET); + + return (FileSize); +} + + /******************************************************************************* * * FUNCTION: FlReadFile @@ -479,6 +465,122 @@ FlSetLineNumber ( } +/******************************************************************************* + * + * FUNCTION: FlAddIncludeDirectory + * + * PARAMETERS: Dir - Directory pathname string + * + * RETURN: None + * + * DESCRIPTION: Add a directory the list of include prefix directories. + * + ******************************************************************************/ + +void +FlAddIncludeDirectory ( + char *Dir) +{ + ASL_INCLUDE_DIR *NewDir; + ASL_INCLUDE_DIR *NextDir; + ASL_INCLUDE_DIR *PrevDir = NULL; + UINT32 NeedsSeparator = 0; + size_t DirLength; + + + DirLength = strlen (Dir); + if (!DirLength) + { + return; + } + + /* Make sure that the pathname ends with a path separator */ + + if ((Dir[DirLength-1] != '/') && + (Dir[DirLength-1] != '\\')) + { + NeedsSeparator = 1; + } + + NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR)); + NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator); + strcpy (NewDir->Dir, Dir); + if (NeedsSeparator) + { + strcat (NewDir->Dir, "/"); + } + + /* + * Preserve command line ordering of -I options by adding new elements + * at the end of the list + */ + NextDir = Gbl_IncludeDirList; + while (NextDir) + { + PrevDir = NextDir; + NextDir = NextDir->Next; + } + + if (PrevDir) + { + PrevDir->Next = NewDir; + } + else + { + Gbl_IncludeDirList = NewDir; + } +} + + +/******************************************************************************* + * + * FUNCTION: FlOpenIncludeWithPrefix + * + * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero + * length string. + * Filename - The include filename from the source ASL. + * + * RETURN: Valid file descriptor if successful. Null otherwise. + * + * DESCRIPTION: Open an include file and push it on the input file stack. + * + ******************************************************************************/ + +static FILE * +FlOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename) +{ + FILE *IncludeFile; + char *Pathname; + + + /* Build the full pathname to the file */ + + Pathname = ACPI_ALLOCATE (strlen (PrefixDir) + strlen (Filename) + 1); + + strcpy (Pathname, PrefixDir); + strcat (Pathname, Filename); + + DbgPrint (ASL_PARSE_OUTPUT, "\nAttempt to open include file: path %s\n\n", + Pathname); + + /* Attempt to open the file, push if successful */ + + IncludeFile = fopen (Pathname, "r"); + if (IncludeFile) + { + /* Push the include file on the open input file stack */ + + AslPushInputFileStack (IncludeFile, Pathname); + return (IncludeFile); + } + + ACPI_FREE (Pathname); + return (NULL); +} + + /******************************************************************************* * * FUNCTION: FlOpenIncludeFile @@ -495,7 +597,8 @@ void FlOpenIncludeFile ( ACPI_PARSE_OBJECT *Op) { - FILE *IncFile; + FILE *IncludeFile; + ASL_INCLUDE_DIR *NextDir; /* Op must be valid */ @@ -518,21 +621,58 @@ FlOpenIncludeFile ( FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n"); Gbl_CurrentLineOffset++; - /* Prepend the directory pathname and open the include file */ - DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", - Op->Asl.Value.String); - IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r"); - if (!IncFile) + /* Attempt to open the include file */ + + /* If the file specifies an absolute path, just open it */ + + if ((Op->Asl.Value.String[0] == '/') || + (Op->Asl.Value.String[0] == '\\') || + (Op->Asl.Value.String[1] == ':')) { - sprintf (MsgBuffer, "%s (%s)", Op->Asl.Value.String, strerror (errno)); - AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer); + IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String); + if (!IncludeFile) + { + goto ErrorExit; + } return; } - /* Push the include file on the open input file stack */ + /* + * The include filename is not an absolute path. + * + * First, search for the file within the "local" directory -- meaning + * the same directory that contains the source file. + * + * Construct the file pathname from the global directory name. + */ + IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String); + if (IncludeFile) + { + return; + } + + /* + * Second, search for the file within the (possibly multiple) directories + * specified by the -I option on the command line. + */ + NextDir = Gbl_IncludeDirList; + while (NextDir) + { + IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String); + if (IncludeFile) + { + return; + } + + NextDir = NextDir->Next; + } + + /* We could not open the include file after trying very hard */ - AslPushInputFileStack (IncFile, Op->Asl.Value.String); +ErrorExit: + sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno)); + AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer); } @@ -628,22 +768,49 @@ FlOpenMiscOutputFiles ( char *Filename; - /* Create/Open a combined source output file */ + /* Create/Open a hex output file if asked */ - Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE); - if (!Filename) + if (Gbl_HexOutputFlag) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, - 0, 0, 0, 0, NULL, NULL); - return (AE_ERROR); + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the hex file, text mode */ + + FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+"); + + AslCompilerSignon (ASL_FILE_HEX_OUTPUT); + AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT); } - /* - * Open the source output file, binary mode (so that LF does not get - * expanded to CR/LF on some systems, messing up our seek - * calculations.) - */ - FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b"); + /* Create/Open a debug output file if asked */ + + if (Gbl_DebugFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the debug file as STDERR, text mode */ + + /* TBD: hide this behind a FlReopenFile function */ + + Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; + Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = + freopen (Filename, "w+t", stderr); + + AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); + AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); + } /* Create/Open a listing output file if asked */ @@ -665,6 +832,28 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT); } + if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA) + { + return (AE_OK); + } + + /* Create/Open a combined source output file */ + + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* + * Open the source output file, binary mode (so that LF does not get + * expanded to CR/LF on some systems, messing up our seek + * calculations.) + */ + FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b"); + /* Create/Open a assembly code source output file if asked */ if (Gbl_AsmOutputFlag) @@ -747,26 +936,6 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT); } - /* Create/Open a hex output file if asked */ - - if (Gbl_HexOutputFlag) - { - Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP); - if (!Filename) - { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, - 0, 0, 0, 0, NULL, NULL); - return (AE_ERROR); - } - - /* Open the hex file, text mode */ - - FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+"); - - AslCompilerSignon (ASL_FILE_HEX_OUTPUT); - AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT); - } - /* Create a namespace output file if asked */ if (Gbl_NsOutputFlag) @@ -787,30 +956,6 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT); } - /* Create/Open a debug output file if asked */ - - if (Gbl_DebugFlag) - { - Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG); - if (!Filename) - { - AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, - 0, 0, 0, 0, NULL, NULL); - return (AE_ERROR); - } - - /* Open the debug file as STDERR, text mode */ - - /* TBD: hide this behind a FlReopenFile function */ - - Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; - Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = - freopen (Filename, "w+t", stderr); - - AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); - AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); - } - return (AE_OK); } diff --git a/sys/contrib/dev/acpica-unix/compiler/aslfold.c b/sys/contrib/dev/acpica-unix/compiler/aslfold.c index 4bb305ef1c..d31c17335d 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslfold.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslfold.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/compiler/aslglobal.h b/sys/contrib/dev/acpica-unix/compiler/aslglobal.h index 4cb91216fb..19c0a94447 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica-unix/compiler/aslglobal.h @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -143,12 +143,11 @@ extern FILE *AslCompilerin; extern int AslCompilerdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; extern char *AslCompilertext; -extern char HexLookup[]; -#define ASL_LINE_BUFFER_SIZE 512 +#define ASL_LINE_BUFFER_SIZE 1024 #define ASL_MSG_BUFFER_SIZE 4096 #define HEX_TABLE_LINE_SIZE 8 -#define HEX_LISTING_LINE_SIZE 16 +#define HEX_LISTING_LINE_SIZE 8 /* Source code buffers and pointers for error reporting */ @@ -165,13 +164,13 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_Curren ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_ErrorLog,NULL); ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_NextError,NULL); -extern UINT32 Gbl_ExceptionCount[]; /* Option flags */ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoCompile, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoSignon, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisassembleAll, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_Acpi2, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE); @@ -189,6 +188,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); @@ -196,11 +196,16 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFl ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseTemplates, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE); #define HEX_OUTPUT_NONE 0 #define HEX_OUTPUT_C 1 #define HEX_OUTPUT_ASM 2 +#define HEX_OUTPUT_ASL 3 + ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE); @@ -209,9 +214,9 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTP ASL_EXTERN ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; ASL_EXTERN char *Gbl_DirectoryPath; -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_ExternalFilename, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL); +ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL); ASL_EXTERN char *Gbl_CurrentInputFilename; ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE); @@ -220,6 +225,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE) /* Statistics */ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_InputByteCount, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_InputFieldCount, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NsLookupCount, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalKeywords, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalNamedObjects, 0); @@ -244,7 +250,9 @@ ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; - +ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); +ASL_EXTERN char *Gbl_TemplateSignature; ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); @@ -261,7 +269,7 @@ ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswin ASL_EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo; ASL_EXTERN ACPI_TABLE_HEADER TableHeader; -extern const ASL_RESERVED_INFO ReservedMethods[]; +extern char AslHexLookup[]; /* Event timing */ @@ -277,5 +285,12 @@ ASL_EXTERN char MsgBuffer[ASL_MSG_BUFFER_SIZE]; ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE]; ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE]; + +#ifdef _DECLARE_GLOBALS +UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; +#else +extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; +#endif + #endif /* __ASLGLOBAL_H */ diff --git a/sys/contrib/dev/acpica-unix/compiler/asllength.c b/sys/contrib/dev/acpica-unix/compiler/asllength.c index bd222e68f4..c3306260fa 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asllength.c +++ b/sys/contrib/dev/acpica-unix/compiler/asllength.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/compiler/asllisting.c b/sys/contrib/dev/acpica-unix/compiler/asllisting.c index f229d5fb78..f46e2cd09f 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asllisting.c +++ b/sys/contrib/dev/acpica-unix/compiler/asllisting.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -198,7 +198,11 @@ static void LsDoHexOutputAsm ( void); -ACPI_STATUS +static void +LsDoHexOutputAsl ( + void); + +static ACPI_STATUS LsTreeWriteWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -218,7 +222,7 @@ LsTreeWriteWalk ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LsTreeWriteWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -1337,6 +1341,11 @@ LsDoHexOutput ( LsDoHexOutputAsm (); break; + case HEX_OUTPUT_ASL: + + LsDoHexOutputAsl (); + break; + default: /* No other output types supported */ break; @@ -1362,60 +1371,160 @@ static void LsDoHexOutputC ( void) { - UINT32 j; - UINT8 FileByte[HEX_TABLE_LINE_SIZE]; - UINT8 Buffer[4]; + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; UINT32 Offset = 0; + UINT32 AmlFileSize; + UINT32 i; - FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n"); + /* Get AML size, seek back to start */ + + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", + AmlFileSize); FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); - /* Start at the beginning of the AML file */ + while (Offset < AmlFileSize) + { + /* Read enough bytes needed for one output line */ - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) + { + break; + } - /* Process all AML bytes in the AML file */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); - j = 0; - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK) - { - if (j == 0) + for (i = 0; i < LineLength; i++) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + /* + * Print each hex byte. + * Add a comma until the very last byte of the AML file + * (Some C compilers complain about a trailing comma) + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); + if ((Offset + i + 1) < AmlFileSize) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } + else + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + } } - /* Convert each AML byte to hex */ + /* Add fill spaces if needed for last line */ - UtConvertByteToHex (FileByte[j], Buffer); - FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); - FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + if (LineLength < HEX_TABLE_LINE_SIZE) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); + } - /* An occasional linefeed improves readability */ + /* Emit the offset and ascii dump for the entire line */ - Offset++; - j++; + FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", + HEX_TABLE_LINE_SIZE - LineLength + 1, " "); - if (j >= HEX_TABLE_LINE_SIZE) - { - /* End of line, emit the ascii dump of the entire line */ + Offset += LineLength; + } - FlPrintFile (ASL_FILE_HEX_OUTPUT, - " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n"); + FlCloseFile (ASL_FILE_HEX_OUTPUT); +} - /* Write the ASCII character associated with each of the bytes */ - LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, - HEX_TABLE_LINE_SIZE, FileByte); - FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n"); +/******************************************************************************* + * + * FUNCTION: LsDoHexOutputAsl + * + * PARAMETERS: None + * + * RETURN: None. + * + * DESCRIPTION: Create the hex output file. This is the same data as the AML + * output file, but formatted into hex/ascii bytes suitable for + * inclusion into a C source file. + * + ******************************************************************************/ - /* Start new line */ +static void +LsDoHexOutputAsl ( + void) +{ + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; + UINT32 Offset = 0; + UINT32 AmlFileSize; + UINT32 i; + + + /* Get AML size, seek back to start */ + + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", + AmlFileSize); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n"); + + while (Offset < AmlFileSize) + { + /* Read enough bytes needed for one output line */ - j = 0; + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) + { + break; } + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + + for (i = 0; i < LineLength; i++) + { + /* + * Print each hex byte. + * Add a comma until the very last byte of the AML file + * (Some C compilers complain about a trailing comma) + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); + if ((Offset + i + 1) < AmlFileSize) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } + else + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + } + } + + /* Add fill spaces if needed for last line */ + + if (LineLength < HEX_TABLE_LINE_SIZE) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); + } + + /* Emit the offset and ascii dump for the entire line */ + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", + HEX_TABLE_LINE_SIZE - LineLength + 1, " "); + + Offset += LineLength; } - FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n"); FlCloseFile (ASL_FILE_HEX_OUTPUT); } @@ -1438,58 +1547,64 @@ static void LsDoHexOutputAsm ( void) { - UINT32 j; - UINT8 FileByte[HEX_TABLE_LINE_SIZE]; - UINT8 Buffer[4]; + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; UINT32 Offset = 0; - BOOLEAN DoComma = FALSE; + UINT32 AmlFileSize; + UINT32 i; - FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n"); + /* Get AML size, seek back to start */ - /* Start at the beginning of the AML file */ + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", + AmlFileSize); - /* Process all AML bytes in the AML file */ - - j = 0; - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK) + while (Offset < AmlFileSize) { - if (j == 0) + /* Read enough bytes needed for one output line */ + + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, " db "); + break; } - else if (DoComma) + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " db "); + + for (i = 0; i < LineLength; i++) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); - DoComma = FALSE; + /* + * Print each hex byte. + * Add a comma until the last byte of the line + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); + if ((i + 1) < LineLength) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } } - /* Convert each AML byte to hex */ - - UtConvertByteToAsmHex (FileByte[j], Buffer); - FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); - /* An occasional linefeed improves readability */ + /* Add fill spaces if needed for last line */ - Offset++; - j++; - if (j >= HEX_TABLE_LINE_SIZE) + if (LineLength < HEX_TABLE_LINE_SIZE) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, - " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); + } - /* Write the ASCII character associated with each of the bytes */ + /* Emit the offset and ascii dump for the entire line */ - LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte); - FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); - j = 0; - } - else - { - DoComma = TRUE; - } + FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); + + Offset += LineLength; } FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); diff --git a/sys/contrib/dev/acpica-unix/compiler/aslload.c b/sys/contrib/dev/acpica-unix/compiler/aslload.c index e61e0622e4..4a8eefdbb0 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslload.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -353,6 +353,7 @@ LdLoadResourceElements ( Node->Value = (UINT32) Op->Asl.Value.Integer; Node->Op = Op; + Op->Asl.Node = Node; /* * Now enter the predefined fields, for easy lookup when referenced @@ -533,7 +534,7 @@ LdNamespace1Begin ( if (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC) { Status = LdLoadResourceElements (Op, WalkState); - goto Exit; + return_ACPI_STATUS (Status); } ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); @@ -574,8 +575,10 @@ LdNamespace1Begin ( goto FinishNode; } - AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE); - goto Exit; + AslCoreSubsystemError (Op, Status, + "Failure from namespace lookup", FALSE); + + return_ACPI_STATUS (Status); } /* We found a node with this name, now check the type */ @@ -710,15 +713,14 @@ LdNamespace1Begin ( AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, Op->Asl.ExternalName); - Status = AE_OK; - goto Exit; + return_ACPI_STATUS (AE_OK); } } else { AslCoreSubsystemError (Op, Status, - "Failure from lookup %s\n", FALSE); - goto Exit; + "Failure from namespace lookup", FALSE); + return_ACPI_STATUS (Status); } } @@ -756,8 +758,7 @@ FinishNode: Node->Value = (UINT32) Op->Asl.Extra; } -Exit: - return (Status); + return_ACPI_STATUS (Status); } @@ -884,7 +885,8 @@ LdNamespace2Begin ( return (AE_OK); } - AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE); + AslCoreSubsystemError (Op, Status, + "Failure from namespace lookup", FALSE); return (AE_OK); } diff --git a/sys/contrib/dev/acpica-unix/compiler/asllookup.c b/sys/contrib/dev/acpica-unix/compiler/asllookup.c index 06113f0784..04cc0f7f6f 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asllookup.c +++ b/sys/contrib/dev/acpica-unix/compiler/asllookup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -180,11 +180,7 @@ LsDoOnePathname ( void *Context, void **ReturnValue); -void -LsSetupNsList ( - void *Handle); - -ACPI_PARSE_OBJECT * +static ACPI_PARSE_OBJECT * LkGetNameOp ( ACPI_PARSE_OBJECT *Op); @@ -216,7 +212,7 @@ LsDoOneNamespaceObject ( Gbl_NumNamespaceObjects++; - FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5d [%d] %*s %4.4s - %s", + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u [%u] %*s %4.4s - %s", Gbl_NumNamespaceObjects, Level, (Level * 3), " ", &Node->Name, AcpiUtGetTypeName (Node->Type)); @@ -526,7 +522,7 @@ LsDisplayNamespace ( /* Walk entire namespace from the root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, + ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, NULL, NULL, NULL); /* Print the full pathname for each namespace node */ @@ -534,7 +530,7 @@ LsDisplayNamespace ( FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LsDoOnePathname, + ACPI_UINT32_MAX, FALSE, LsDoOnePathname, NULL, NULL, NULL); return (Status); @@ -598,7 +594,7 @@ LkObjectExists ( /* Walk entire namespace from the supplied root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, + ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, NULL, Name, NULL); if (Status == AE_CTRL_TRUE) { @@ -623,7 +619,7 @@ LkObjectExists ( * ******************************************************************************/ -ACPI_PARSE_OBJECT * +static ACPI_PARSE_OBJECT * LkGetNameOp ( ACPI_PARSE_OBJECT *Op) { @@ -753,7 +749,7 @@ LkFindUnreferencedObjects ( /* Walk entire namespace from the supplied root */ (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, + ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL, NULL, NULL); } @@ -1245,7 +1241,7 @@ LkNamespaceLocateBegin ( */ if (PassedArgs != Node->Value) { - sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName, + sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, Node->Value); if (PassedArgs < Node->Value) @@ -1337,6 +1333,7 @@ LkNamespaceLocateBegin ( break; case REGION_SMBUS: + case REGION_IPMI: if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) { diff --git a/sys/contrib/dev/acpica-unix/compiler/aslmain.c b/sys/contrib/dev/acpica-unix/compiler/aslmain.c index d006955243..d35ad89397 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslmain.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslmain.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +119,7 @@ #include "aslcompiler.h" #include "acapps.h" +#include "acdisasm.h" #ifdef _DEBUG #include @@ -150,6 +151,25 @@ AslCommandLine ( int argc, char **argv); +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile); + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer); + +static int +AslDoResponseFile ( + char *Filename); + + +#define ASL_TOKEN_SEPARATORS " \t\n" +#define ASL_SUPPORTED_OPTIONS "@:2b:c:d^e:fgh^i^I:l^no:p:r:s:t:T:v:w:x:z" + /******************************************************************************* * @@ -168,8 +188,12 @@ Options ( void) { - printf ("General Output:\n"); - printf (" -p Specify path/filename prefix for all output files\n"); + printf ("Global:\n"); + printf (" -@ Specify command file\n"); + printf (" -I Specify additional include directory\n"); + + printf ("\nGeneral Output:\n"); + printf (" -p Specify path/filename prefix for all output files\n"); printf (" -va Disable all errors and warnings (summary only)\n"); printf (" -vi Less verbose errors and warnings for use with IDEs\n"); printf (" -vo Enable optimization comments\n"); @@ -180,22 +204,28 @@ Options ( printf ("\nAML Output Files:\n"); printf (" -s Create AML in assembler or C source file (*.asm or *.c)\n"); printf (" -i Create assembler or C include file (*.inc or *.h)\n"); - printf (" -t Create AML in assembler or C hex table (*.hex)\n"); + printf (" -t Create AML in assembler, C, or ASL hex table (*.hex)\n"); printf ("\nAML Code Generation:\n"); printf (" -oa Disable all optimizations (compatibility mode)\n"); printf (" -of Disable constant folding\n"); printf (" -oi Disable integer optimization to Zero/One/Ones\n"); printf (" -on Disable named reference string optimization\n"); + printf (" -cr Disable Resource Descriptor error checking\n"); printf (" -r Override table header Revision (1-255)\n"); - printf ("\nListings:\n"); + printf ("\nASL Listing Files:\n"); printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n"); printf (" -ln Create namespace file (*.nsp)\n"); printf (" -ls Create combined source file (expanded includes) (*.src)\n"); + printf ("\nACPI Data Tables:\n"); + printf (" -T Create table template file for (or \"ALL\")\n"); + printf (" -vt Create verbose templates (full disassembly)\n"); + printf ("\nAML Disassembler:\n"); printf (" -d [file] Disassemble or decode binary ACPI table to file (*.dsl)\n"); + printf (" -da [f1,f2] Disassemble multiple tables from single namespace\n"); printf (" -dc [file] Disassemble AML and immediately compile it\n"); printf (" (Obtain DSDT from current system if no input file)\n"); printf (" -e [f1,f2] Include ACPI table(s) for external symbol resolution\n"); @@ -206,6 +236,7 @@ Options ( printf (" -h Additional help and compiler debug options\n"); printf (" -hc Display operators allowed in constant expressions\n"); printf (" -hr Display ACPI reserved method names\n"); + printf (" -ht Display currently supported ACPI table names\n"); } @@ -241,9 +272,10 @@ HelpMessage ( printf (" -b Create compiler debug/trace file (*.txt)\n"); printf (" Types: Parse/Tree/Both\n"); printf (" -f Ignore errors, force creation of AML output file(s)\n"); - printf (" -c Parse only, no output generation\n"); + printf (" -n Parse only, no output generation\n"); printf (" -ot Display compile times\n"); printf (" -x Set debug level for trace output\n"); + printf (" -z Do not insert new compiler ID for DataTables\n"); } @@ -264,7 +296,8 @@ Usage ( void) { - printf ("Usage: %s [Options] [Files]\n\n", CompilerName); + printf ("%s\n", ASL_COMPLIANCE); + printf ("Usage: %s [Options] [Files]\n\n", ASL_INVOCATION_NAME); Options (); } @@ -310,39 +343,150 @@ AslInitialize ( /******************************************************************************* * - * FUNCTION: AslCommandLine + * FUNCTION: AslMergeOptionTokens * - * PARAMETERS: argc/argv + * PARAMETERS: InBuffer - Input containing an option string + * OutBuffer - Merged output buffer * * RETURN: None * - * DESCRIPTION: Command line processing + * DESCRIPTION: Remove all whitespace from an option string. + * + ******************************************************************************/ + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer) +{ + char *Token; + + + *OutBuffer = 0; + + Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); + while (Token) + { + strcat (OutBuffer, Token); + Token = strtok (NULL, ASL_TOKEN_SEPARATORS); + } +} + + +/******************************************************************************* + * + * FUNCTION: AslDoResponseFile + * + * PARAMETERS: Filename - Name of the response file + * + * RETURN: Status + * + * DESCRIPTION: Open a response file and process all options within. * ******************************************************************************/ static int -AslCommandLine ( - int argc, - char **argv) +AslDoResponseFile ( + char *Filename) { - BOOLEAN BadCommandLine = FALSE; - int j; + char *argv = StringBuffer2; + FILE *ResponseFile; + int OptStatus = 0; + int Opterr; + int Optind; + + ResponseFile = fopen (Filename, "r"); + if (!ResponseFile) + { + printf ("Could not open command file %s, %s\n", + Filename, strerror (errno)); + return -1; + } - /* Minimum command line contains at least one option or an input file */ + /* Must save the current GetOpt globals */ - if (argc < 2) + Opterr = AcpiGbl_Opterr; + Optind = AcpiGbl_Optind; + + /* + * Process all lines in the response file. There must be one complete + * option per line + */ + while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) { - AslCompilerSignon (ASL_FILE_STDOUT); - Usage (); - exit (1); + /* Compress all tokens, allowing us to use a single argv entry */ + + AslMergeOptionTokens (StringBuffer, StringBuffer2); + + /* Process the option */ + + AcpiGbl_Opterr = 0; + AcpiGbl_Optind = 0; + + OptStatus = AslDoOptions (1, &argv, TRUE); + if (OptStatus) + { + printf ("Invalid option in command file %s: %s\n", + Filename, StringBuffer); + break; + } } + /* Restore the GetOpt globals */ + + AcpiGbl_Opterr = Opterr; + AcpiGbl_Optind = Optind; + + fclose (ResponseFile); + return (OptStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AslDoOptions + * + * PARAMETERS: argc/argv - Standard argc/argv + * IsResponseFile - TRUE if executing a response file. + * + * RETURN: Status + * + * DESCRIPTION: Command line option processing + * + ******************************************************************************/ + +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile) +{ + int j; + ACPI_STATUS Status; + + /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, "2b:cd^e:fgh^i^l^o:p:r:s:t:v:w:x:")) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) { + case '@': /* Begin a response file */ + + if (IsResponseFile) + { + printf ("Nested command files are not supported\n"); + return -1; + } + + if (AslDoResponseFile (AcpiGbl_Optarg)) + { + return -1; + } + break; + + case '2': + Gbl_Acpi2 = TRUE; break; @@ -364,8 +508,7 @@ AslCommandLine ( default: printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } /* Produce debug output file */ @@ -375,10 +518,16 @@ AslCommandLine ( case 'c': + switch (AcpiGbl_Optarg[0]) + { + case 'r': + Gbl_NoResourceChecking = TRUE; + break; - /* Parse only */ - - Gbl_ParseOnlyFlag = TRUE; + default: + printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); + return (-1); + } break; @@ -389,13 +538,17 @@ AslCommandLine ( Gbl_DoCompile = FALSE; break; + case 'a': + Gbl_DoCompile = FALSE; + Gbl_DisassembleAll = TRUE; + break; + case 'c': break; default: printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } Gbl_DisasmFlag = TRUE; @@ -403,7 +556,12 @@ AslCommandLine ( case 'e': - Gbl_ExternalFilename = AcpiGbl_Optarg; + Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); + if (ACPI_FAILURE (Status)) + { + printf ("Could not add %s to external list\n", AcpiGbl_Optarg); + return (-1); + } break; @@ -439,14 +597,22 @@ AslCommandLine ( case 'r': /* reserved names */ - MpDisplayReservedNames (); + ApDisplayReservedNames (); + exit (0); + + case 't': + UtDisplaySupportedTables (); exit (0); default: printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } + + + case 'I': /* Add an include file search directory */ + + FlAddIncludeDirectory (AcpiGbl_Optarg); break; @@ -470,8 +636,7 @@ AslCommandLine ( default: printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -500,8 +665,7 @@ AslCommandLine ( default: printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -549,12 +713,19 @@ AslCommandLine ( default: printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; + case 'n': + + /* Parse only */ + + Gbl_ParseOnlyFlag = TRUE; + break; + + case 'p': /* Override default AML output filename */ @@ -589,8 +760,7 @@ AslCommandLine ( default: printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -609,14 +779,23 @@ AslCommandLine ( Gbl_HexOutputFlag = HEX_OUTPUT_C; break; + case 's': + Gbl_HexOutputFlag = HEX_OUTPUT_ASL; + break; + default: printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; + case 'T': + Gbl_DoTemplates = TRUE; + Gbl_TemplateSignature = AcpiGbl_Optarg; + break; + + case 'v': switch (AcpiGbl_Optarg[0]) @@ -645,10 +824,13 @@ AslCommandLine ( Gbl_DoSignon = FALSE; break; + case 't': + Gbl_VerboseTemplates = TRUE; + break; + default: printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -671,8 +853,7 @@ AslCommandLine ( default: printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); - BadCommandLine = TRUE; - break; + return (-1); } break; @@ -683,10 +864,63 @@ AslCommandLine ( break; - default: + case 'z': - BadCommandLine = TRUE; + Gbl_UseOriginalCompilerId = TRUE; break; + + + default: + + return (-1); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AslCommandLine + * + * PARAMETERS: argc/argv + * + * RETURN: Last argv index + * + * DESCRIPTION: Command line processing + * + ******************************************************************************/ + +static int +AslCommandLine ( + int argc, + char **argv) +{ + int BadCommandLine = 0; + ACPI_STATUS Status; + + + /* Minimum command line contains at least the command and an input file */ + + if (argc < 2) + { + printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); + Usage (); + exit (1); + } + + /* Process all command line options */ + + BadCommandLine = AslDoOptions (argc, argv, FALSE); + + if (Gbl_DoTemplates) + { + Status = DtCreateTemplates (Gbl_TemplateSignature); + if (ACPI_FAILURE (Status)) + { + exit (-1); + } + exit (1); } /* Next parameter must be the input filename */ @@ -701,7 +935,7 @@ AslCommandLine ( if (Gbl_DoSignon) { - AslCompilerSignon (ASL_FILE_STDOUT); + printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); } /* Abort if anything went wrong on the command line */ @@ -736,8 +970,11 @@ main ( char **argv) { ACPI_STATUS Status; - int Index; + int Index1; + int Index2; + + AcpiGbl_ExternalFileList = NULL; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | @@ -747,7 +984,7 @@ main ( /* Init and command line */ AslInitialize (); - Index = AslCommandLine (argc, argv); + Index1 = Index2 = AslCommandLine (argc, argv); /* Options that have no additional parameters or pathnames */ @@ -761,17 +998,36 @@ main ( return (0); } + if (Gbl_DisassembleAll) + { + while (argv[Index1]) + { + Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + + Index1++; + } + } + /* Process each pathname/filename in the list, with possible wildcards */ - while (argv[Index]) + while (argv[Index2]) { - Status = AslDoOnePathname (argv[Index]); + Status = AslDoOnePathname (argv[Index2], AslDoOneFile); if (ACPI_FAILURE (Status)) { return (-1); } - Index++; + Index2++; + } + + if (AcpiGbl_ExternalFileList) + { + AcpiDmClearExternalFileList(); } return (0); diff --git a/sys/contrib/dev/acpica-unix/compiler/aslmap.c b/sys/contrib/dev/acpica-unix/compiler/aslmap.c index f96e78c141..cb5feb518a 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslmap.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslmap.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,7 +114,6 @@ * *****************************************************************************/ - #include "aslcompiler.h" #include "amlcode.h" #include "acparser.h" @@ -169,290 +168,6 @@ AslMapNamedOpcodeToDataType ( } -/******************************************************************************* - * - * FUNCTION: MpDisplayReservedNames - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Print the table above - * - ******************************************************************************/ - -void -MpDisplayReservedNames ( - void) -{ - UINT32 i; - - printf ("Reserved name information\n\n"); - - for (i = 0; ReservedMethods[i].Name; i++) - { - printf ("%s ", ReservedMethods[i].Name); - - if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) - { - printf ("Reserved scope name\n"); - } - else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) - { - printf ("Resource data type reserved field name\n"); - } - else - { - printf ("Method with %d arguments, ", - ReservedMethods[i].NumArguments & 0x0F); - - if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE) - { - printf ("must return a value\n"); - } - else - { - printf ("no return value\n"); - } - } - } -} - - -/******************************************************************************* - * - * DATA STRUCTURE: ReservedMethods - * - * DESCRIPTION: Contains all reserved methods and names as defined in the - * ACPI specification. Used during the analysis phase to - * ensure that reserved methods have the required number of - * arguments and the proper return type. - * - * Each entry in the table contains the following items: - * - * Name - The ACPI reserved name - * Args - Number of arguments to the method - * Flags - Whether this method must return a value or not - * - ******************************************************************************/ - -const ASL_RESERVED_INFO ReservedMethods[] = { - {"_AC0", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC1", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC2", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC3", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC4", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC5", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC6", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC7", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC8", 0, ASL_RSVD_RETURN_VALUE}, - {"_AC9", 0, ASL_RSVD_RETURN_VALUE}, - {"_ADR", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL0", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL1", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL2", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL3", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL4", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL5", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL6", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL7", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL8", 0, ASL_RSVD_RETURN_VALUE}, - {"_AL9", 0, ASL_RSVD_RETURN_VALUE}, - {"_ALC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_ALI", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_ALN", 0, ASL_RSVD_RESOURCE_NAME}, - {"_ALP", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_ALR", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_ALT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_ASI", 0, ASL_RSVD_RESOURCE_NAME}, - {"_ASZ", 0, ASL_RSVD_RESOURCE_NAME}, - {"_BAS", 0, ASL_RSVD_RESOURCE_NAME}, - {"_BBN", 0, ASL_RSVD_RETURN_VALUE}, - {"_BCL", 0, ASL_RSVD_RETURN_VALUE}, - {"_BCM", 1, 0}, - {"_BDN", 0, ASL_RSVD_RETURN_VALUE}, - {"_BFS", 1, 0}, - {"_BIF", 0, ASL_RSVD_RETURN_VALUE}, - {"_BLT", 3, 0}, /* Acpi 3.0 */ - {"_BM_", 0, ASL_RSVD_RESOURCE_NAME}, - {"_BMC", 1, 0}, /* Acpi 3.0 */ - {"_BMD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_BQC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_BST", 0, ASL_RSVD_RETURN_VALUE}, - {"_BTM", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_BTP", 1, 0}, - {"_CBA", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_CID", 0, ASL_RSVD_RETURN_VALUE}, - {"_CRS", 0, ASL_RSVD_RETURN_VALUE}, - {"_CRT", 0, ASL_RSVD_RETURN_VALUE}, - {"_CSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_CST", 0, ASL_RSVD_RETURN_VALUE}, - {"_DCK", 1, ASL_RSVD_RETURN_VALUE}, - {"_DCS", 0, ASL_RSVD_RETURN_VALUE}, - {"_DDC", 1, ASL_RSVD_RETURN_VALUE}, - {"_DDN", 0, 0}, - {"_DEC", 0, ASL_RSVD_RESOURCE_NAME}, - {"_DGS", 0, ASL_RSVD_RETURN_VALUE}, - {"_DIS", 0, 0}, - {"_DMA", 0, ASL_RSVD_RETURN_VALUE}, - {"_DOD", 0, ASL_RSVD_RETURN_VALUE}, - {"_DOS", 1, 0}, - {"_DSM", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_DSS", 1, 0}, - {"_DSW", 3, 0}, /* Acpi 3.0 */ - {"_EC_", 0, ASL_RSVD_RETURN_VALUE}, - {"_EDL", 0, ASL_RSVD_RETURN_VALUE}, - {"_EJ0", 1, 0}, - {"_EJ1", 1, 0}, - {"_EJ2", 1, 0}, - {"_EJ3", 1, 0}, - {"_EJ4", 1, 0}, - {"_EJD", 0, ASL_RSVD_RETURN_VALUE}, - {"_ERR", 3, ASL_RSVD_RETURN_VALUE}, - {"_FDE", 0, ASL_RSVD_RETURN_VALUE}, - {"_FDI", 0, ASL_RSVD_RETURN_VALUE}, - {"_FDM", 1, 0}, - {"_FIX", 0, ASL_RSVD_RETURN_VALUE}, - {"_GL_", 0, ASL_RSVD_RETURN_VALUE}, - {"_GLK", 0, ASL_RSVD_RETURN_VALUE}, - {"_GPD", 0, ASL_RSVD_RETURN_VALUE}, - {"_GPE", 0, ASL_RSVD_RETURN_VALUE}, - {"_GRA", 0, ASL_RSVD_RESOURCE_NAME}, - {"_GSB", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_GTF", 0, ASL_RSVD_RETURN_VALUE}, - {"_GTM", 0, ASL_RSVD_RETURN_VALUE}, - {"_GTS", 1, 0}, - {"_HE_", 0, ASL_RSVD_RESOURCE_NAME}, - {"_HID", 0, ASL_RSVD_RETURN_VALUE}, - {"_HOT", 0, ASL_RSVD_RETURN_VALUE}, - {"_HPP", 0, ASL_RSVD_RETURN_VALUE}, - {"_HPX", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_IFT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_INI", 0, 0}, - {"_INT", 0, ASL_RSVD_RESOURCE_NAME}, - {"_IRC", 0, 0}, - {"_LCK", 1, 0}, - {"_LEN", 0, ASL_RSVD_RESOURCE_NAME}, - {"_LID", 0, ASL_RSVD_RETURN_VALUE}, - {"_LL_", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MAF", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MAT", 0, ASL_RSVD_RETURN_VALUE}, - {"_MAX", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MEM", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MIF", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MIN", 0, ASL_RSVD_RESOURCE_NAME}, - {"_MLS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_MSG", 1, 0}, - {"_MTP", 0, ASL_RSVD_RESOURCE_NAME}, - {"_OFF", 0, 0}, - {"_ON_", 0, 0}, - {"_OS_", 0, ASL_RSVD_RETURN_VALUE}, - {"_OSC", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_OSI", 1, ASL_RSVD_RETURN_VALUE}, - {"_OST", 3, 0}, /* Acpi 3.0 */ - {"_PCL", 0, ASL_RSVD_RETURN_VALUE}, - {"_PCT", 0, ASL_RSVD_RETURN_VALUE}, - {"_PDC", 1, 0}, - {"_PIC", 1, 0}, - {"_PLD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_PPC", 0, ASL_RSVD_RETURN_VALUE}, - {"_PPE", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_PR0", 0, ASL_RSVD_RETURN_VALUE}, - {"_PR1", 0, ASL_RSVD_RETURN_VALUE}, - {"_PR2", 0, ASL_RSVD_RETURN_VALUE}, - {"_PRS", 0, ASL_RSVD_RETURN_VALUE}, - {"_PRT", 0, ASL_RSVD_RETURN_VALUE}, - {"_PRW", 0, ASL_RSVD_RETURN_VALUE}, - {"_PS0", 0, 0}, - {"_PS1", 0, 0}, - {"_PS2", 0, 0}, - {"_PS3", 0, 0}, - {"_PSC", 0, ASL_RSVD_RETURN_VALUE}, - {"_PSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_PSL", 0, ASL_RSVD_RETURN_VALUE}, - {"_PSR", 0, ASL_RSVD_RETURN_VALUE}, - {"_PSS", 0, ASL_RSVD_RETURN_VALUE}, - {"_PSV", 0, ASL_RSVD_RETURN_VALUE}, - {"_PSW", 1, 0}, - {"_PTC", 0, ASL_RSVD_RETURN_VALUE}, - {"_PTS", 1, 0}, - {"_PXM", 0, ASL_RSVD_RETURN_VALUE}, - {"_RBO", 0, ASL_RSVD_RESOURCE_NAME}, - {"_RBW", 0, ASL_RSVD_RESOURCE_NAME}, - {"_REG", 2, 0}, - {"_REV", 0, ASL_RSVD_RETURN_VALUE}, - {"_RMV", 0, ASL_RSVD_RETURN_VALUE}, - {"_RNG", 0, ASL_RSVD_RESOURCE_NAME}, - {"_ROM", 2, ASL_RSVD_RETURN_VALUE}, - {"_RT_", 0, ASL_RSVD_RESOURCE_NAME}, /* Acpi 3.0 */ - {"_RTV", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_RW_", 0, ASL_RSVD_RESOURCE_NAME}, - {"_S0_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S1_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S2_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S3_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S4_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S5_", 0, ASL_RSVD_RETURN_VALUE}, - {"_S1D", 0, ASL_RSVD_RETURN_VALUE}, - {"_S2D", 0, ASL_RSVD_RETURN_VALUE}, - {"_S3D", 0, ASL_RSVD_RETURN_VALUE}, - {"_S4D", 0, ASL_RSVD_RETURN_VALUE}, - {"_S0W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_S1W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_S2W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_S3W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_S4W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_SB_", 0, ASL_RSVD_SCOPE}, - {"_SBS", 0, ASL_RSVD_RETURN_VALUE}, - {"_SCP", 0x13, 0}, /* Acpi 1.0 - one arg; Acpi 3.0 - three args */ - {"_SDD", 1, 0}, /* Acpi 3.0 */ - {"_SEG", 0, ASL_RSVD_RETURN_VALUE}, - {"_SHR", 0, ASL_RSVD_RESOURCE_NAME}, - {"_SI_", 0, ASL_RSVD_SCOPE}, - {"_SIZ", 0, ASL_RSVD_RESOURCE_NAME}, - {"_SLI", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_SPD", 1, ASL_RSVD_RETURN_VALUE}, - {"_SRS", 1, 0}, - {"_SRV", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_SST", 1, 0}, - {"_STA", 0, ASL_RSVD_RETURN_VALUE}, - {"_STM", 3, 0}, - {"_STR", 0, ASL_RSVD_RETURN_VALUE}, - {"_SUN", 0, ASL_RSVD_RETURN_VALUE}, - {"_SWS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TC1", 0, ASL_RSVD_RETURN_VALUE}, - {"_TC2", 0, ASL_RSVD_RETURN_VALUE}, - {"_TDL", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0b */ - {"_TMP", 0, ASL_RSVD_RETURN_VALUE}, - {"_TPC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TPT", 1, 0}, /* Acpi 3.0 */ - {"_TRA", 0, ASL_RSVD_RESOURCE_NAME}, - {"_TRS", 0, ASL_RSVD_RESOURCE_NAME}, - {"_TRT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TSF", 0, ASL_RSVD_RESOURCE_NAME}, /* Acpi 3.0 */ - {"_TSP", 0, ASL_RSVD_RETURN_VALUE}, - {"_TSS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TST", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TTP", 0, ASL_RSVD_RESOURCE_NAME}, - {"_TTS", 1, 0}, /* Acpi 3.0 */ - {"_TYP", 0, ASL_RSVD_RESOURCE_NAME}, - {"_TZ_", 0, ASL_RSVD_SCOPE}, - {"_TZD", 0, ASL_RSVD_RETURN_VALUE}, - {"_TZM", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_TZP", 0, ASL_RSVD_RETURN_VALUE}, - {"_UID", 0, ASL_RSVD_RETURN_VALUE}, - {"_UPC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_UPD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_UPP", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ - {"_VPO", 0, ASL_RSVD_RETURN_VALUE}, - {"_WAK", 1, ASL_RSVD_RETURN_VALUE}, - {"_WDG", 0, ASL_RSVD_RETURN_VALUE}, /* MS Extension */ - {"_WED", 1, ASL_RSVD_RETURN_VALUE}, /* MS Extension */ - {NULL, 0, 0}, -}; - - /******************************************************************************* * * DATA STRUCTURE: AslKeywordMapping @@ -681,6 +396,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_CMOS, 0, 0), /* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_EC, 0, 0), /* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IO, 0, 0), +/* REGIONSPACE_IPMI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IPMI, 0, 0), /* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_MEMORY, 0, 0), /* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_CONFIG, 0, 0), /* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_BAR, 0, 0), diff --git a/sys/contrib/dev/acpica-unix/compiler/asltypes.h b/sys/contrib/dev/acpica-unix/compiler/aslmessages.h similarity index 77% copy from sys/contrib/dev/acpica-unix/compiler/asltypes.h copy to sys/contrib/dev/acpica-unix/compiler/aslmessages.h index 6b3c4243bb..748492c58c 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asltypes.h +++ b/sys/contrib/dev/acpica-unix/compiler/aslmessages.h @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: asltypes.h - compiler data types and struct definitions + * Module Name: aslmessages.h - Compiler error/warning messages * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -115,192 +115,8 @@ *****************************************************************************/ -#ifndef __ASLTYPES_H -#define __ASLTYPES_H - - -/******************************************************************************* - * - * Structure definitions - * - ******************************************************************************/ - - -/* Op flags for the ACPI_PARSE_OBJECT */ - -#define NODE_VISITED 0x00000001 -#define NODE_AML_PACKAGE 0x00000002 -#define NODE_IS_TARGET 0x00000004 -#define NODE_IS_RESOURCE_DESC 0x00000008 -#define NODE_IS_RESOURCE_FIELD 0x00000010 -#define NODE_HAS_NO_EXIT 0x00000020 -#define NODE_IF_HAS_NO_EXIT 0x00000040 -#define NODE_NAME_INTERNALIZED 0x00000080 -#define NODE_METHOD_NO_RETVAL 0x00000100 -#define NODE_METHOD_SOME_NO_RETVAL 0x00000200 -#define NODE_RESULT_NOT_USED 0x00000400 -#define NODE_METHOD_TYPED 0x00000800 -#define NODE_IS_BIT_OFFSET 0x00001000 -#define NODE_COMPILE_TIME_CONST 0x00002000 -#define NODE_IS_TERM_ARG 0x00004000 -#define NODE_WAS_ONES_OP 0x00008000 -#define NODE_IS_NAME_DECLARATION 0x00010000 -#define NODE_COMPILER_EMITTED 0x00020000 -#define NODE_IS_DUPLICATE 0x00040000 -#define NODE_IS_RESOURCE_DATA 0x00080000 - -/* Keeps information about individual control methods */ - -typedef struct asl_method_info -{ - UINT8 NumArguments; - UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS]; - UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS]; - UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; - UINT32 ValidReturnTypes; - UINT32 NumReturnNoValue; - UINT32 NumReturnWithValue; - ACPI_PARSE_OBJECT *Op; - struct asl_method_info *Next; - UINT8 HasBeenTyped; - -} ASL_METHOD_INFO; - - -/* Parse tree walk info for control method analysis */ - -typedef struct asl_analysis_walk_info -{ - ASL_METHOD_INFO *MethodStack; - -} ASL_ANALYSIS_WALK_INFO; - - -/* An entry in the ParseOpcode to AmlOpcode mapping table */ - -typedef struct asl_mapping_entry -{ - UINT32 Value; - UINT32 AcpiBtype; /* Object type or return type */ - UINT16 AmlOpcode; - UINT8 Flags; - -} ASL_MAPPING_ENTRY; - - -/* An entry in the Reserved Name information table */ - -#define ASL_RSVD_RETURN_VALUE 0x01 -#define ASL_RSVD_RESOURCE_NAME 0x02 -#define ASL_RSVD_SCOPE 0x04 - -typedef struct asl_reserved_info -{ - char *Name; - UINT8 NumArguments; - UINT8 Flags; - -} ASL_RESERVED_INFO; - - -/* Parse tree walk info structure */ - -typedef struct asl_walk_info -{ - ACPI_PARSE_OBJECT **NodePtr; - UINT32 *LevelPtr; - -} ASL_WALK_INFO; - - -/* File info */ - -typedef struct asl_file_info -{ - FILE *Handle; - char *Filename; - -} ASL_FILE_INFO; - -typedef struct asl_file_status -{ - UINT32 Line; - UINT32 Offset; - -} ASL_FILE_STATUS; - - -/* File types */ - -typedef enum -{ - ASL_FILE_STDOUT = 0, - ASL_FILE_STDERR, - ASL_FILE_INPUT, - ASL_FILE_AML_OUTPUT, - ASL_FILE_SOURCE_OUTPUT, - ASL_FILE_LISTING_OUTPUT, - ASL_FILE_HEX_OUTPUT, - ASL_FILE_NAMESPACE_OUTPUT, - ASL_FILE_DEBUG_OUTPUT, - ASL_FILE_ASM_SOURCE_OUTPUT, - ASL_FILE_C_SOURCE_OUTPUT, - ASL_FILE_ASM_INCLUDE_OUTPUT, - ASL_FILE_C_INCLUDE_OUTPUT - -} ASL_FILE_TYPES; - - -#define ASL_MAX_FILE_TYPE 12 -#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) - - -/* An entry in the exception list, one for each error/warning */ - -typedef struct asl_error_msg -{ - UINT32 LineNumber; - UINT32 LogicalLineNumber; - UINT32 LogicalByteOffset; - UINT32 Column; - char *Message; - struct asl_error_msg *Next; - char *Filename; - UINT32 FilenameLength; - UINT8 MessageId; - UINT8 Level; - -} ASL_ERROR_MSG; - - -/* An entry in the listing file stack (for include files) */ - -typedef struct asl_listing_node -{ - char *Filename; - UINT32 LineNumber; - struct asl_listing_node *Next; - -} ASL_LISTING_NODE; - - -/* Callback interface for a parse tree walk */ - -typedef -ACPI_STATUS (*ASL_WALK_CALLBACK) ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - - -typedef struct asl_event_info -{ - UINT64 StartTime; - UINT64 EndTime; - char *EventName; - BOOLEAN Valid; - -} ASL_EVENT_INFO; +#ifndef __ASLMESSAGES_H +#define __ASLMESSAGES_H #define ASL_WARNING 0 @@ -312,6 +128,8 @@ typedef struct asl_event_info #define ASL_NUM_REPORT_LEVELS 6 +/* Values for all compiler messages */ + typedef enum { ASL_MSG_RESERVED = 0, @@ -361,7 +179,8 @@ typedef enum ASL_MSG_INVALID_TIME, ASL_MSG_INVALID_TYPE, ASL_MSG_INVALID_UUID, - ASL_MSG_LIST_LENGTH, + ASL_MSG_LIST_LENGTH_LONG, + ASL_MSG_LIST_LENGTH_SHORT, ASL_MSG_LISTING_FILE_OPEN, ASL_MSG_LISTING_FILENAME, ASL_MSG_LOCAL_INIT, @@ -426,14 +245,47 @@ typedef enum ASL_MSG_SERIALIZED, ASL_MSG_COMPILER_RESERVED, ASL_MSG_NAMED_OBJECT_IN_WHILE, - ASL_MSG_LOCAL_OUTSIDE_METHOD + ASL_MSG_LOCAL_OUTSIDE_METHOD, + ASL_MSG_ALIGNMENT, + ASL_MSG_ISA_ADDRESS, + ASL_MSG_INVALID_MIN_MAX, + ASL_MSG_INVALID_LENGTH, + ASL_MSG_INVALID_LENGTH_FIXED, + ASL_MSG_INVALID_GRANULARITY, + ASL_MSG_INVALID_GRAN_FIXED, + ASL_MSG_INVALID_ACCESS_SIZE, + ASL_MSG_INVALID_ADDR_FLAGS, + ASL_MSG_NULL_DESCRIPTOR, + ASL_MSG_UPPER_CASE, + ASL_MSG_HID_LENGTH, + ASL_MSG_NULL_STRING, + ASL_MSG_LEADING_ASTERISK, + ASL_MSG_RESERVED_NO_RETURN_VAL, + ASL_MSG_GPE_NAME_CONFLICT, + + ASL_MSG_INVALID_FIELD_NAME, + ASL_MSG_INTEGER_SIZE, + ASL_MSG_INVALID_HEX_INTEGER, + ASL_MSG_BUFFER_ELEMENT, + ASL_MSG_RESERVED_VALUE, + ASL_MSG_FLAG_VALUE, + ASL_MSG_ZERO_VALUE, + ASL_MSG_UNKNOWN_TABLE, + ASL_MSG_UNKNOWN_SUBTABLE, + ASL_MSG_OEM_TABLE, + ASL_MSG_UNKNOWN_LABEL, + ASL_MSG_INVALID_EXPRESSION, + ASL_MSG_DIVIDE_BY_ZERO } ASL_MESSAGE_IDS; + #ifdef ASL_EXCEPTIONS +/* Actual message strings for each compiler message */ + char *AslMessages [] = { -/* The zeroth message is resesrved */ "", +/* The zeroth message is reserved */ "", /* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", /* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", /* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", @@ -480,7 +332,8 @@ char *AslMessages [] = { /* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", /* ASL_MSG_INVALID_TYPE */ "Invalid type", /* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", -/* ASL_MSG_LIST_LENGTH */ "Initializer list too long", +/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length", +/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length", /* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", /* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", /* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", @@ -512,7 +365,7 @@ char *AslMessages [] = { /* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", /* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", /* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", -/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid operand type for reserved name, must be", +/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name", /* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", /* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", /* ASL_MSG_RESERVED_WORD */ "Use of reserved name", @@ -537,7 +390,7 @@ char *AslMessages [] = { /* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", /* ASL_MSG_WRITE */ "Could not write file", /* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", -/* ASL_MSG_TIMEOUT */ "Possible operator timeout is ignored", +/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", /* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", /* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", /* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", @@ -545,7 +398,39 @@ char *AslMessages [] = { /* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", /* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", /* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", -/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method" +/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", +/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", +/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", +/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", +/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", +/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", +/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", +/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", +/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", +/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags", +/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", +/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case", +/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters", +/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", +/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk", +/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value", +/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method", + +/* These messages are used by the data table compiler only */ + +/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name", +/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target", +/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant", +/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list", +/* ASL_MSG_RESERVED_VALUE */ "Reserved field must be zero", +/* ASL_MSG_FLAG_VALUE */ "Flag value is too large", +/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero", +/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature", +/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type", +/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents", +/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined", +/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression", +/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero" }; @@ -561,11 +446,6 @@ char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { #define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ -/* Exception counters */ - -UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; - -#endif - +#endif /* ASL_EXCEPTIONS */ -#endif /* __ASLTYPES_H */ +#endif /* __ASLMESSAGES_H */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslopcodes.c b/sys/contrib/dev/acpica-unix/compiler/aslopcodes.c index e386266427..9f84953f94 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslopcodes.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -123,13 +123,6 @@ ACPI_MODULE_NAME ("aslopcodes") -/* UUID support */ - -static UINT8 OpcMapToUUID[16] = -{ - 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 -}; - /* Local prototypes */ static void @@ -328,7 +321,7 @@ OpcSetOptimalIntegerSize ( } break; - case ACPI_INTEGER_MAX: + case ACPI_UINT64_MAX: /* Check for table integer width (32 or 64) */ @@ -568,7 +561,7 @@ OpcDoEisaId ( if (i < 3) { - if (!isupper (InString[i])) + if (!isupper ((int) InString[i])) { Status = AE_BAD_PARAMETER; } @@ -576,7 +569,7 @@ OpcDoEisaId ( /* Last 4 characters must be hex digits */ - else if (!isxdigit (InString[i])) + else if (!isxdigit ((int) InString[i])) { Status = AE_BAD_PARAMETER; } @@ -592,9 +585,9 @@ OpcDoEisaId ( /* Create ID big-endian first (bits are contiguous) */ BigEndianId = - (UINT32) (InString[0] - 0x40) << 26 | - (UINT32) (InString[1] - 0x40) << 21 | - (UINT32) (InString[2] - 0x40) << 16 | + (UINT32) ((UINT8) (InString[0] - 0x40)) << 26 | + (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 | + (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 | (UtHexCharToValue (InString[3])) << 12 | (UtHexCharToValue (InString[4])) << 8 | @@ -641,49 +634,20 @@ OpcDoUuId ( char *InString; char *Buffer; ACPI_STATUS Status = AE_OK; - UINT32 i; ACPI_PARSE_OBJECT *NewOp; InString = (char *) Op->Asl.Value.String; - - if (ACPI_STRLEN (InString) != 36) - { - Status = AE_BAD_PARAMETER; - } - else - { - /* Check all 36 characters for correct format */ - - for (i = 0; i < 36; i++) - { - if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) - { - if (InString[i] != '-') - { - Status = AE_BAD_PARAMETER; - } - } - else - { - if (!isxdigit (InString[i])) - { - Status = AE_BAD_PARAMETER; - } - } - } - } - Buffer = UtLocalCalloc (16); + Status = AuValidateUuid (InString); if (ACPI_FAILURE (Status)) { AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String); } - else for (i = 0; i < 16; i++) + else { - Buffer[i] = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4); - Buffer[i] |= (char) UtHexCharToValue (InString[OpcMapToUUID[i] + 1]); + (void) AuConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ diff --git a/sys/contrib/dev/acpica-unix/compiler/asloperands.c b/sys/contrib/dev/acpica-unix/compiler/asloperands.c index c354855dd6..e0280befb8 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asloperands.c +++ b/sys/contrib/dev/acpica-unix/compiler/asloperands.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -604,7 +604,7 @@ OpnDoRegion ( } else { - Op->Asl.Value.Integer = ACPI_INTEGER_MAX; + Op->Asl.Value.Integer = ACPI_UINT64_MAX; } } @@ -788,20 +788,30 @@ OpnDoPackage ( if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)) { - if (PackageLengthOp->Asl.Value.Integer >= PackageLength) + if (PackageLengthOp->Asl.Value.Integer > PackageLength) { - /* Allow package to be longer than the initializer list */ + /* + * Allow package length to be longer than the initializer + * list -- but if the length of initializer list is nonzero, + * issue a message since this is probably a coding error, + * even though technically legal. + */ + if (PackageLength > 0) + { + AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT, + PackageLengthOp, NULL); + } PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer; } - else + else if (PackageLengthOp->Asl.Value.Integer < PackageLength) { /* - * Initializer list is longer than the package length. This - * is an error as per the ACPI spec. + * The package length is smaller than the length of the + * initializer list. This is an error as per the ACPI spec. */ - AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH, - PackageLengthOp->Asl.Next, NULL); + AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG, + PackageLengthOp, NULL); } } @@ -997,7 +1007,7 @@ OpnDoDefinitionBlock ( for (i = 0; i < 4; i++) { - if (!isalnum (Gbl_TableSignature[i])) + if (!isalnum ((int) Gbl_TableSignature[i])) { AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, "Contains non-alphanumeric characters"); diff --git a/sys/contrib/dev/acpica-unix/compiler/aslopt.c b/sys/contrib/dev/acpica-unix/compiler/aslopt.c index 3013f4cbd2..6ea357a5be 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslopt.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslopt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -339,7 +339,7 @@ OptBuildShortestPath ( } } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %u", NumCommonSegments)); /* There must be at least 1 common NameSeg in order to optimize */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslpredef.c b/sys/contrib/dev/acpica-unix/compiler/aslpredef.c new file mode 100644 index 0000000000..bcec467eb2 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslpredef.c @@ -0,0 +1,889 @@ +/****************************************************************************** + * + * Module Name: aslpredef - support for ACPI predefined names + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define ACPI_CREATE_PREDEFINED_TABLE + +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslpredef") + + +/* Local prototypes */ + +static void +ApCheckForUnexpectedReturnValue ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo); + +static UINT32 +ApCheckForSpecialName ( + ACPI_PARSE_OBJECT *Op, + char *Name); + +static void +ApCheckObjectType ( + ACPI_PARSE_OBJECT *Op, + UINT32 ExpectedBtypes); + +static void +ApGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + +/* + * Predefined names for use in Resource Descriptors. These names do not + * appear in the global Predefined Name table (since these names never + * appear in actual AML byte code, only in the original ASL) + */ +static const ACPI_PREDEFINED_INFO ResourceNames[] = { + {{"_ALN", 0, 0}}, + {{"_ASI", 0, 0}}, + {{"_ASZ", 0, 0}}, + {{"_ATT", 0, 0}}, + {{"_BAS", 0, 0}}, + {{"_BM_", 0, 0}}, + {{"_DEC", 0, 0}}, + {{"_GRA", 0, 0}}, + {{"_HE_", 0, 0}}, + {{"_INT", 0, 0}}, + {{"_LEN", 0, 0}}, + {{"_LL_", 0, 0}}, + {{"_MAF", 0, 0}}, + {{"_MAX", 0, 0}}, + {{"_MEM", 0, 0}}, + {{"_MIF", 0, 0}}, + {{"_MIN", 0, 0}}, + {{"_MTP", 0, 0}}, + {{"_RBO", 0, 0}}, + {{"_RBW", 0, 0}}, + {{"_RNG", 0, 0}}, + {{"_RT_", 0, 0}}, /* Acpi 3.0 */ + {{"_RW_", 0, 0}}, + {{"_SHR", 0, 0}}, + {{"_SIZ", 0, 0}}, + {{"_TRA", 0, 0}}, + {{"_TRS", 0, 0}}, + {{"_TSF", 0, 0}}, /* Acpi 3.0 */ + {{"_TTP", 0, 0}}, + {{"_TYP", 0, 0}}, + {{{0,0,0,0}, 0, 0}} /* Table terminator */ +}; + +static const ACPI_PREDEFINED_INFO ScopeNames[] = { + {{"_SB_", 0, 0}}, + {{"_SI_", 0, 0}}, + {{"_TZ_", 0, 0}}, + {{{0,0,0,0}, 0, 0}} /* Table terminator */ +}; + + +/******************************************************************************* + * + * FUNCTION: ApCheckForPredefinedMethod + * + * PARAMETERS: Op - A parse node of type "METHOD". + * MethodInfo - Saved info about this method + * + * RETURN: None + * + * DESCRIPTION: If method is a predefined name, check that the number of + * arguments and the return type (returns a value or not) + * is correct. + * + ******************************************************************************/ + +void +ApCheckForPredefinedMethod ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo) +{ + UINT32 Index; + UINT32 RequiredArgsCurrent; + UINT32 RequiredArgsOld; + + + /* Check for a match against the predefined name list */ + + Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); + + switch (Index) + { + case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ + case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ + case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ + + /* Just return, nothing to do */ + break; + + + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ + + Gbl_ReservedMethods++; + + /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ + + if (MethodInfo->NumArguments != 0) + { + sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, 0); + + AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, + MsgBuffer); + } + break; + + + default: + /* + * Matched a predefined method name + * + * Validate the ASL-defined argument count. Allow two different legal + * arg counts. + */ + Gbl_ReservedMethods++; + + RequiredArgsCurrent = PredefinedNames[Index].Info.ParamCount & 0x0F; + RequiredArgsOld = PredefinedNames[Index].Info.ParamCount >> 4; + + if ((MethodInfo->NumArguments != RequiredArgsCurrent) && + (MethodInfo->NumArguments != RequiredArgsOld)) + { + sprintf (MsgBuffer, "%4.4s requires %u", + PredefinedNames[Index].Info.Name, RequiredArgsCurrent); + + if (MethodInfo->NumArguments > RequiredArgsCurrent) + { + AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, + MsgBuffer); + } + else + { + AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, + MsgBuffer); + } + } + + /* + * Check if method returns no value, but the predefined name is + * required to return a value + */ + if (MethodInfo->NumReturnNoValue && + PredefinedNames[Index].Info.ExpectedBtypes) + { + ApGetExpectedTypes (StringBuffer, + PredefinedNames[Index].Info.ExpectedBtypes); + + sprintf (MsgBuffer, "%s required for %4.4s", + StringBuffer, PredefinedNames[Index].Info.Name); + + AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, + MsgBuffer); + } + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckForUnexpectedReturnValue + * + * PARAMETERS: Op - A parse node of type "RETURN". + * MethodInfo - Saved info about this method + * + * RETURN: None + * + * DESCRIPTION: Check for an unexpected return value from a predefined method. + * Invoked for predefined methods that are defined to not return + * any value. If there is a return value, issue a remark, since + * the ASL writer may be confused as to the method definition + * and/or functionality. + * + * Note: We ignore all return values of "Zero", since this is what a standalone + * Return() statement will always generate -- so we ignore it here -- + * i.e., there is no difference between Return() and Return(Zero). + * Also, a null Return() will be disassembled to return(Zero) -- so, we + * don't want to generate extraneous remarks/warnings for a disassembled + * ASL file. + * + ******************************************************************************/ + +static void +ApCheckForUnexpectedReturnValue ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo) +{ + ACPI_PARSE_OBJECT *ReturnValueOp; + + + /* Ignore Return() and Return(Zero) (they are the same) */ + + ReturnValueOp = Op->Asl.Child; + if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO) + { + return; + } + + /* We have a valid return value, but the reserved name did not expect it */ + + AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL, + Op, MethodInfo->Op->Asl.ExternalName); +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckPredefinedReturnValue + * + * PARAMETERS: Op - A parse node of type "RETURN". + * MethodInfo - Saved info about this method + * + * RETURN: None + * + * DESCRIPTION: If method is a predefined name, attempt to validate the return + * value. Only "static" types can be validated - a simple return + * of an integer/string/buffer/package or a named reference to + * a static object. Values such as a Localx or Argx or a control + * method invocation are not checked. Issue a warning if there is + * a valid return value, but the reserved method defines no + * return value. + * + ******************************************************************************/ + +void +ApCheckPredefinedReturnValue ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo) +{ + UINT32 Index; + ACPI_PARSE_OBJECT *ReturnValueOp; + + + /* Check parent method for a match against the predefined name list */ + + Index = ApCheckForPredefinedName (MethodInfo->Op, + MethodInfo->Op->Asl.NameSeg); + + switch (Index) + { + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ + + /* No return value expected, warn if there is one */ + + ApCheckForUnexpectedReturnValue (Op, MethodInfo); + return; + + case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ + case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ + case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ + + /* Just return, nothing to do */ + return; + + default: /* A standard predefined ACPI name */ + + if (!PredefinedNames[Index].Info.ExpectedBtypes) + { + /* No return value expected, warn if there is one */ + + ApCheckForUnexpectedReturnValue (Op, MethodInfo); + return; + } + + /* Get the object returned, it is the next argument */ + + ReturnValueOp = Op->Asl.Child; + switch (ReturnValueOp->Asl.ParseOpcode) + { + case PARSEOP_ZERO: + case PARSEOP_ONE: + case PARSEOP_ONES: + case PARSEOP_INTEGER: + case PARSEOP_STRING_LITERAL: + case PARSEOP_BUFFER: + case PARSEOP_PACKAGE: + + /* Static data return object - check against expected type */ + + ApCheckObjectType (ReturnValueOp, + PredefinedNames[Index].Info.ExpectedBtypes); + break; + + default: + + /* + * All other ops are very difficult or impossible to typecheck at + * compile time. These include all Localx, Argx, and method + * invocations. Also, NAMESEG and NAMESTRING because the type of + * any named object can be changed at runtime (for example, + * CopyObject will change the type of the target object.) + */ + break; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckForPredefinedObject + * + * PARAMETERS: Op - A parse node + * Name - The ACPI name to be checked + * + * RETURN: None + * + * DESCRIPTION: Check for a predefined name for a static object (created via + * the ASL Name operator). If it is a predefined ACPI name, ensure + * that the name does not require any arguments (which would + * require a control method implemenation of the name), and that + * the type of the object is one of the expected types for the + * predefined name. + * + ******************************************************************************/ + +void +ApCheckForPredefinedObject ( + ACPI_PARSE_OBJECT *Op, + char *Name) +{ + UINT32 Index; + + + /* + * Check for a real predefined name -- not a resource descriptor name + * or a predefined scope name + */ + Index = ApCheckForPredefinedName (Op, Name); + + switch (Index) + { + case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ + case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ + case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ + + /* Nothing to do */ + return; + + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ + + /* + * These names must be control methods, by definition in ACPI spec. + * Also because they are defined to return no value. None of them + * require any arguments. + */ + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with zero arguments"); + return; + + default: /* A standard predefined ACPI name */ + + /* + * If this predefined name requires input arguments, then + * it must be implemented as a control method + */ + if (PredefinedNames[Index].Info.ParamCount > 0) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with arguments"); + return; + } + + /* + * If no return value is expected from this predefined name, then + * it follows that it must be implemented as a control method + * (with zero args, because the args > 0 case was handled above) + * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx + */ + if (!PredefinedNames[Index].Info.ExpectedBtypes) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with zero arguments"); + return; + } + + /* Typecheck the actual object, it is the next argument */ + + ApCheckObjectType (Op->Asl.Child->Asl.Next, + PredefinedNames[Index].Info.ExpectedBtypes); + return; + } +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckForPredefinedName + * + * PARAMETERS: Op - A parse node + * Name - NameSeg to check + * + * RETURN: None + * + * DESCRIPTION: Check a NameSeg against the reserved list. + * + ******************************************************************************/ + +UINT32 +ApCheckForPredefinedName ( + ACPI_PARSE_OBJECT *Op, + char *Name) +{ + UINT32 i; + + + if (Name[0] == 0) + { + AcpiOsPrintf ("Found a null name, external = %s\n", + Op->Asl.ExternalName); + } + + /* All reserved names are prefixed with a single underscore */ + + if (Name[0] != '_') + { + return (ACPI_NOT_RESERVED_NAME); + } + + /* Check for a standard predefined method name */ + + for (i = 0; PredefinedNames[i].Info.Name[0]; i++) + { + if (ACPI_COMPARE_NAME (Name, PredefinedNames[i].Info.Name)) + { + /* Return index into predefined array */ + return (i); + } + } + + /* Check for resource names and predefined scope names */ + + for (i = 0; ResourceNames[i].Info.Name[0]; i++) + { + if (ACPI_COMPARE_NAME (Name, ResourceNames[i].Info.Name)) + { + return (ACPI_PREDEFINED_NAME); + } + } + + for (i = 0; ScopeNames[i].Info.Name[0]; i++) + { + if (ACPI_COMPARE_NAME (Name, ScopeNames[i].Info.Name)) + { + return (ACPI_PREDEFINED_NAME); + } + } + + /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */ + + return (ApCheckForSpecialName (Op, Name)); +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckForSpecialName + * + * PARAMETERS: Op - A parse node + * Name - NameSeg to check + * + * RETURN: None + * + * DESCRIPTION: Check for the "special" predefined names - + * _Lxx, _Exx, _Qxx, _Wxx, and _T_x + * + ******************************************************************************/ + +static UINT32 +ApCheckForSpecialName ( + ACPI_PARSE_OBJECT *Op, + char *Name) +{ + + /* + * Check for the "special" predefined names. We already know that the + * first character is an underscore. + * GPE: _Lxx + * GPE: _Exx + * GPE: _Wxx + * EC: _Qxx + */ + if ((Name[1] == 'L') || + (Name[1] == 'E') || + (Name[1] == 'W') || + (Name[1] == 'Q')) + { + /* The next two characters must be hex digits */ + + if ((isxdigit ((int) Name[2])) && + (isxdigit ((int) Name[3]))) + { + return (ACPI_EVENT_RESERVED_NAME); + } + } + + /* Check for the names reserved for the compiler itself: _T_x */ + + else if ((Op->Asl.ExternalName[1] == 'T') && + (Op->Asl.ExternalName[2] == '_')) + { + /* Ignore if actually emitted by the compiler */ + + if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED) + { + return (ACPI_NOT_RESERVED_NAME); + } + + /* + * Was not actually emitted by the compiler. This is a special case, + * however. If the ASL code being compiled was the result of a + * dissasembly, it may possibly contain valid compiler-emitted names + * of the form "_T_x". We don't want to issue an error or even a + * warning and force the user to manually change the names. So, we + * will issue a remark instead. + */ + AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); + return (ACPI_COMPILER_RESERVED_NAME); + } + + /* + * The name didn't match any of the known predefined names. Flag it as a + * warning, since the entire namespace starting with an underscore is + * reserved by the ACPI spec. + */ + AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, + Op->Asl.ExternalName); + + return (ACPI_NOT_RESERVED_NAME); +} + + +/******************************************************************************* + * + * FUNCTION: ApCheckObjectType + * + * PARAMETERS: Op - Current parse node + * ExpectedBtypes - Bitmap of expected return type(s) + * + * RETURN: None + * + * DESCRIPTION: Check if the object type is one of the types that is expected + * by the predefined name. Only a limited number of object types + * can be returned by the predefined names. + * + ******************************************************************************/ + +static void +ApCheckObjectType ( + ACPI_PARSE_OBJECT *Op, + UINT32 ExpectedBtypes) +{ + UINT32 ReturnBtype; + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_ZERO: + case PARSEOP_ONE: + case PARSEOP_ONES: + case PARSEOP_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; + break; + + case PARSEOP_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; + break; + + case PARSEOP_STRING_LITERAL: + ReturnBtype = ACPI_RTYPE_STRING; + break; + + case PARSEOP_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; + break; + + default: + /* Not one of the supported object types */ + + goto TypeErrorExit; + } + + /* Exit if the object is one of the expected types */ + + if (ReturnBtype & ExpectedBtypes) + { + return; + } + + +TypeErrorExit: + + /* Format the expected types and emit an error message */ + + ApGetExpectedTypes (StringBuffer, ExpectedBtypes); + + sprintf (MsgBuffer, "found %s, requires %s", + UtGetOpName (Op->Asl.ParseOpcode), StringBuffer); + + AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, + MsgBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: ApDisplayReservedNames + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump information about the ACPI predefined names and predefined + * resource descriptor names. + * + ******************************************************************************/ + +void +ApDisplayReservedNames ( + void) +{ + const ACPI_PREDEFINED_INFO *ThisName; + char TypeBuffer[48]; /* Room for 5 types */ + UINT32 Count; + + + /* + * Predefined names/methods + */ + printf ("\nPredefined Name Information\n\n"); + + Count = 0; + ThisName = PredefinedNames; + while (ThisName->Info.Name[0]) + { + printf ("%4.4s Requires %u arguments, ", + ThisName->Info.Name, ThisName->Info.ParamCount & 0x0F); + + if (ThisName->Info.ExpectedBtypes) + { + ApGetExpectedTypes (TypeBuffer, ThisName->Info.ExpectedBtypes); + printf ("Must return: %s\n", TypeBuffer); + } + else + { + printf ("No return value\n"); + } + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + + Count++; + ThisName++; + } + + printf ("%u Predefined Names are recognized\n", Count); + + /* + * Resource Descriptor names + */ + printf ("\nResource Descriptor Predefined Names\n\n"); + + Count = 0; + ThisName = ResourceNames; + while (ThisName->Info.Name[0]) + { + printf ("%4.4s Resource Descriptor\n", ThisName->Info.Name); + Count++; + ThisName++; + } + + printf ("%u Resource Descriptor Names are recognized\n", Count); + + /* + * Predefined scope names + */ + printf ("\nPredefined Scope Names\n\n"); + + ThisName = ScopeNames; + while (ThisName->Info.Name[0]) + { + printf ("%4.4s Scope\n", ThisName->Info.Name); + ThisName++; + } +} + + +/******************************************************************************* + * + * FUNCTION: ApGetExpectedTypes + * + * PARAMETERS: Buffer - Where the formatted string is returned + * ExpectedBTypes - Bitfield of expected data types + * + * RETURN: None, formatted string + * + * DESCRIPTION: Format the expected object types into a printable string. + * + ******************************************************************************/ + +static void +ApGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} diff --git a/sys/contrib/dev/acpica-unix/compiler/aslresource.c b/sys/contrib/dev/acpica-unix/compiler/aslresource.c index ceebd9c1e8..116c083d5e 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslresource.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslresource.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslresource - Resource templates and descriptors + * Module Name: aslresource - Resource template/descriptor utilities * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,356 @@ ACPI_MODULE_NAME ("aslresource") +/******************************************************************************* + * + * FUNCTION: RsSmallAddressCheck + * + * PARAMETERS: Minimum - Address Min value + * Maximum - Address Max value + * Length - Address range value + * Alignment - Address alignment value + * MinOp - Original Op for Address Min + * MaxOp - Original Op for Address Max + * LengthOp - Original Op for address range + * AlignOp - Original Op for address alignment. If + * NULL, means "zero value for alignment is + * OK, and means 64K alignment" (for + * Memory24 descriptor) + * Op - Parent Op for entire construct + * + * RETURN: None. Adds error messages to error log if necessary + * + * DESCRIPTION: Perform common value checks for "small" address descriptors. + * Currently: + * Io, Memory24, Memory32 + * + ******************************************************************************/ + +void +RsSmallAddressCheck ( + UINT8 Type, + UINT32 Minimum, + UINT32 Maximum, + UINT32 Length, + UINT32 Alignment, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *AlignOp, + ACPI_PARSE_OBJECT *Op) +{ + + if (Gbl_NoResourceChecking) + { + return; + } + + /* + * Check for a so-called "null descriptor". These are descriptors that are + * created with most fields set to zero. The intent is that the descriptor + * will be updated/completed at runtime via a BufferField. + * + * If the descriptor does NOT have a resource tag, it cannot be referenced + * by a BufferField and we will flag this as an error. Conversely, if + * the descriptor has a resource tag, we will assume that a BufferField + * will be used to dynamically update it, so no error. + * + * A possible enhancement to this check would be to verify that in fact + * a BufferField is created using the resource tag, and perhaps even + * verify that a Store is performed to the BufferField. + * + * Note: for these descriptors, Alignment is allowed to be zero + */ + if (!Minimum && !Maximum && !Length) + { + if (!Op->Asl.ExternalName) + { + /* No resource tag. Descriptor is fixed and is also illegal */ + + AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL); + } + + return; + } + + /* Special case for Memory24, values are compressed */ + + if (Type == ACPI_RESOURCE_NAME_MEMORY24) + { + if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */ + { + Alignment = ACPI_UINT16_MAX + 1; + } + + Minimum <<= 8; + Maximum <<= 8; + Length *= 256; + } + + /* IO descriptor has different definition of min/max, don't check */ + + if (Type != ACPI_RESOURCE_NAME_IO) + { + /* Basic checks on Min/Max/Length */ + + if (Minimum > Maximum) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); + } + else if (Length > (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); + } + } + + /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ + + if (!Alignment) + { + Alignment = 1; + } + + /* Addresses must be an exact multiple of the alignment value */ + + if (Minimum % Alignment) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); + } + if (Maximum % Alignment) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL); + } +} + + +/******************************************************************************* + * + * FUNCTION: RsLargeAddressCheck + * + * PARAMETERS: Minimum - Address Min value + * Maximum - Address Max value + * Length - Address range value + * Granularity - Address granularity value + * Flags - General flags for address descriptors: + * _MIF, _MAF, _DEC + * MinOp - Original Op for Address Min + * MaxOp - Original Op for Address Max + * LengthOp - Original Op for address range + * GranOp - Original Op for address granularity + * Op - Parent Op for entire construct + * + * RETURN: None. Adds error messages to error log if necessary + * + * DESCRIPTION: Perform common value checks for "large" address descriptors. + * Currently: + * WordIo, WordBusNumber, WordSpace + * DWordIo, DWordMemory, DWordSpace + * QWordIo, QWordMemory, QWordSpace + * ExtendedIo, ExtendedMemory, ExtendedSpace + * + * _MIF flag set means that the minimum address is fixed and is not relocatable + * _MAF flag set means that the maximum address is fixed and is not relocatable + * Length of zero means that the record size is variable + * + * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40 + * of the ACPI 4.0a specification. Added 04/2010. + * + ******************************************************************************/ + +void +RsLargeAddressCheck ( + UINT64 Minimum, + UINT64 Maximum, + UINT64 Length, + UINT64 Granularity, + UINT8 Flags, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *GranOp, + ACPI_PARSE_OBJECT *Op) +{ + + if (Gbl_NoResourceChecking) + { + return; + } + + /* + * Check for a so-called "null descriptor". These are descriptors that are + * created with most fields set to zero. The intent is that the descriptor + * will be updated/completed at runtime via a BufferField. + * + * If the descriptor does NOT have a resource tag, it cannot be referenced + * by a BufferField and we will flag this as an error. Conversely, if + * the descriptor has a resource tag, we will assume that a BufferField + * will be used to dynamically update it, so no error. + * + * A possible enhancement to this check would be to verify that in fact + * a BufferField is created using the resource tag, and perhaps even + * verify that a Store is performed to the BufferField. + */ + if (!Minimum && !Maximum && !Length && !Granularity) + { + if (!Op->Asl.ExternalName) + { + /* No resource tag. Descriptor is fixed and is also illegal */ + + AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL); + } + + return; + } + + /* Basic checks on Min/Max/Length */ + + if (Minimum > Maximum) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); + return; + } + else if (Length > (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); + return; + } + + /* If specified (non-zero), ensure granularity is a power-of-two minus one */ + + if (Granularity) + { + if ((Granularity + 1) & + Granularity) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL); + return; + } + } + + /* + * Check the various combinations of Length, MinFixed, and MaxFixed + */ + if (Length) + { + /* Fixed non-zero length */ + + switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) + { + case 0: + /* + * Fixed length, variable locations (both _MIN and _MAX). + * Length must be a multiple of granularity + */ + if (Granularity & Length) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL); + } + break; + + case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): + + /* Fixed length, fixed location. Granularity must be zero */ + + if (Granularity != 0) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL); + } + + /* Length must be exactly the size of the min/max window */ + + if (Length != (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL); + } + break; + + /* All other combinations are invalid */ + + case ACPI_RESOURCE_FLAG_MIF: + case ACPI_RESOURCE_FLAG_MAF: + default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); + } + } + else + { + /* Variable length (length==0) */ + + switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) + { + case 0: + /* + * Both _MIN and _MAX are variable. + * No additional requirements, just exit + */ + break; + + case ACPI_RESOURCE_FLAG_MIF: + + /* _MIN is fixed. _MIN must be multiple of _GRA */ + + /* + * The granularity is defined by the ACPI specification to be a + * power-of-two minus one, therefore the granularity is a + * bitmask which can be used to easily validate the addresses. + */ + if (Granularity & Minimum) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); + } + break; + + case ACPI_RESOURCE_FLAG_MAF: + + /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */ + + if (Granularity & (Maximum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1"); + } + break; + + /* Both MIF/MAF set is invalid if length is zero */ + + case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): + default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: RsGetStringDataLength + * + * PARAMETERS: InitializerOp - Start of a subtree of init nodes + * + * RETURN: Valid string length if a string node is found (otherwise 0) + * + * DESCRIPTION: In a list of peer nodes, find the first one that contains a + * string and return the length of the string. + * + ******************************************************************************/ + +UINT16 +RsGetStringDataLength ( + ACPI_PARSE_OBJECT *InitializerOp) +{ + + while (InitializerOp) + { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) + { + return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); + } + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); + } + + return 0; +} + + /******************************************************************************* * * FUNCTION: RsAllocateResourceNode @@ -184,7 +534,7 @@ RsCreateBitField ( { Op->Asl.ExternalName = Name; - Op->Asl.Value.Integer = ((ACPI_INTEGER) ByteOffset * 8) + BitOffset; + Op->Asl.Value.Integer = ((UINT64) ByteOffset * 8) + BitOffset; Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET); } diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c index edc8405403..0d0e6cc5d6 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslrestype1 - Short (type1) resource templates and descriptors + * Module Name: aslrestype1 - Miscellaneous small resource descriptors * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -121,6 +121,18 @@ #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslrestype1") +/* + * This module contains miscellaneous small resource descriptors: + * + * EndTag + * EndDependentFn + * Memory24 + * Memory32 + * Memory32Fixed + * StartDependentFn + * StartDependentFnNoPri + * VendorShort + */ /******************************************************************************* * @@ -156,127 +168,6 @@ RsDoEndTagDescriptor ( } -/******************************************************************************* - * - * FUNCTION: RsDoDmaDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "DMA" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - UINT8 DmaChannelMask = 0; - UINT8 DmaChannels = 0; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); - - Descriptor = Rnode->Buffer; - Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | - ASL_RDESC_DMA_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* DMA type */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); - break; - - case 1: /* Bus Master */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); - break; - - case 2: /* Xfer Type (transfer width) */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); - break; - - case 3: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* All DMA channel bytes are handled here, after flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 8 channels can be specified in the list */ - - DmaChannels++; - if (DmaChannels > 8) - { - AslError (ASL_ERROR, ASL_MSG_DMA_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only DMA channels 0-7 are allowed (mask is 8 bits) */ - - if (InitializerOp->Asl.Value.Integer > 7) - { - AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL, - InitializerOp, NULL); - } - - /* Build the mask */ - - DmaChannelMask |= - (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); - } - - if (i == 4) /* case 4: First DMA byte */ - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA, - CurrentByteOffset + - ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the channel mask */ - - Descriptor->Dma.DmaChannelMask = DmaChannelMask; - return (Rnode); -} - - /******************************************************************************* * * FUNCTION: RsDoEndDependentDescriptor @@ -309,396 +200,6 @@ RsDoEndDependentDescriptor ( } -/******************************************************************************* - * - * FUNCTION: RsDoFixedIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "FixedIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); - - Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | - ASL_RDESC_FIXED_IO_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Base Address */ - - Descriptor->FixedIo.Address = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); - break; - - case 1: /* Length */ - - Descriptor->FixedIo.AddressLength = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength)); - break; - - case 2: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); - - Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | - ASL_RDESC_IO_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Decode size */ - - RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0); - break; - - case 1: /* Min Address */ - - Descriptor->Io.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); - break; - - case 2: /* Max Address */ - - Descriptor->Io.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); - break; - - case 3: /* Alignment */ - - Descriptor->Io.Alignment = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); - break; - - case 4: /* Length */ - - Descriptor->Io.AddressLength = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); - break; - - case 5: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIrqDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IRQ" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 Interrupts = 0; - UINT16 IrqMask = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); - - /* Length = 3 (with flag byte) */ - - Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - (ASL_RDESC_IRQ_SIZE + 0x01); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Interrupt Type (or Mode - edge/level) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); - break; - - case 1: /* Interrupt Level (or Polarity - Active high/low) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); - break; - - case 2: /* Share Type - Default: exclusive (0) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); - break; - - case 3: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* All IRQ bytes are handled here, after the flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 16 interrupts can be specified in the list */ - - Interrupts++; - if (Interrupts > 16) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only interrupts 0-15 are allowed (mask is 16 bits) */ - - if (InitializerOp->Asl.Value.Integer > 15) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, - InitializerOp, NULL); - } - else - { - IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); - } - } - - /* Case 4: First IRQ value in list */ - - if (i == 4) - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the channel mask */ - - Descriptor->Irq.IrqMask = IrqMask; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIrqNoFlagsDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IRQNoFlags" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 IrqMask = 0; - UINT32 Interrupts = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); - - Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - ASL_RDESC_IRQ_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* IRQ bytes are handled here, after the flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 16 interrupts can be specified in the list */ - - Interrupts++; - if (Interrupts > 16) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only interrupts 0-15 are allowed (mask is 16 bits) */ - - if (InitializerOp->Asl.Value.Integer > 15) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, - InitializerOp, NULL); - } - else - { - IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); - } - } - - /* Case 1: First IRQ value in list */ - - if (i == 1) - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the interrupt mask */ - - Descriptor->Irq.IrqMask = IrqMask; - return (Rnode); -} - - /******************************************************************************* * * FUNCTION: RsDoMemory24Descriptor @@ -720,6 +221,9 @@ RsDoMemory24Descriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -749,6 +253,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); + MinOp = InitializerOp; break; case 2: /* Max Address */ @@ -756,6 +261,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); + MaxOp = InitializerOp; break; case 3: /* Alignment */ @@ -770,6 +276,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); + LengthOp = InitializerOp; break; case 5: /* Name */ @@ -786,6 +293,15 @@ RsDoMemory24Descriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24, + Descriptor->Memory24.Minimum, + Descriptor->Memory24.Maximum, + Descriptor->Memory24.AddressLength, + Descriptor->Memory24.Alignment, + MinOp, MaxOp, LengthOp, NULL, Op); + return (Rnode); } @@ -811,6 +327,10 @@ RsDoMemory32Descriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -840,6 +360,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); + MinOp = InitializerOp; break; case 2: /* Max Address */ @@ -847,6 +368,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); + MaxOp = InitializerOp; break; case 3: /* Alignment */ @@ -854,6 +376,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); + AlignOp = InitializerOp; break; case 4: /* Length */ @@ -861,6 +384,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); + LengthOp = InitializerOp; break; case 5: /* Name */ @@ -877,6 +401,15 @@ RsDoMemory32Descriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Validate the Min/Max/Len/Align values */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32, + Descriptor->Memory32.Minimum, + Descriptor->Memory32.Maximum, + Descriptor->Memory32.AddressLength, + Descriptor->Memory32.Alignment, + MinOp, MaxOp, LengthOp, AlignOp, Op); + return (Rnode); } @@ -1027,6 +560,7 @@ RsDoStartDependentDescriptor ( break; default: + NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State); @@ -1036,7 +570,6 @@ RsDoStartDependentDescriptor ( * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); break; @@ -1182,4 +715,3 @@ RsDoVendorSmallDescriptor ( return (Rnode); } - diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype1i.c similarity index 55% copy from sys/contrib/dev/acpica-unix/compiler/aslrestype1.c copy to sys/contrib/dev/acpica-unix/compiler/aslrestype1i.c index edc8405403..491ae2f31b 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype1i.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslrestype1 - Short (type1) resource templates and descriptors + * Module Name: aslrestype1i - Small I/O-related resource descriptors * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,42 +119,17 @@ #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslrestype1") + ACPI_MODULE_NAME ("aslrestype1i") - -/******************************************************************************* - * - * FUNCTION: RsDoEndTagDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) +/* + * This module contains the I/O-related small resource descriptors: * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "EndDependentFn" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoEndTagDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ASL_RESOURCE_NODE *Rnode; - - - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG)); - - Descriptor = Rnode->Buffer; - Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | - ASL_RDESC_END_TAG_SIZE; - Descriptor->EndTag.Checksum = 0; - - return (Rnode); -} - + * DMA + * FixedIO + * IO + * IRQ + * IRQNoFlags + */ /******************************************************************************* * @@ -277,38 +252,6 @@ RsDoDmaDescriptor ( } -/******************************************************************************* - * - * FUNCTION: RsDoEndDependentDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "EndDependentFn" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoEndDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ASL_RESOURCE_NODE *Rnode; - - - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); - - Descriptor = Rnode->Buffer; - Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | - ASL_RDESC_END_DEPEND_SIZE; - return (Rnode); -} - - /******************************************************************************* * * FUNCTION: RsDoFixedIoDescriptor @@ -330,6 +273,7 @@ RsDoFixedIoDescriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *AddressOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -353,6 +297,7 @@ RsDoFixedIoDescriptor ( (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); + AddressOp = InitializerOp; break; case 1: /* Length */ @@ -377,6 +322,13 @@ RsDoFixedIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Error checks */ + + if (Descriptor->FixedIo.Address > 0x03FF) + { + AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL); + } + return (Rnode); } @@ -402,6 +354,10 @@ RsDoIoDescriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -432,6 +388,7 @@ RsDoIoDescriptor ( (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); + MinOp = InitializerOp; break; case 2: /* Max Address */ @@ -440,6 +397,7 @@ RsDoIoDescriptor ( (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); + MaxOp = InitializerOp; break; case 3: /* Alignment */ @@ -448,6 +406,7 @@ RsDoIoDescriptor ( (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); + AlignOp = InitializerOp; break; case 4: /* Length */ @@ -456,6 +415,7 @@ RsDoIoDescriptor ( (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); + LengthOp = InitializerOp; break; case 5: /* Name */ @@ -472,6 +432,15 @@ RsDoIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Validate the Min/Max/Len/Align values */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO, + Descriptor->Io.Minimum, + Descriptor->Io.Maximum, + Descriptor->Io.AddressLength, + Descriptor->Io.Alignment, + MinOp, MaxOp, LengthOp, AlignOp, Op); + return (Rnode); } @@ -697,489 +666,3 @@ RsDoIrqNoFlagsDescriptor ( Descriptor->Irq.IrqMask = IrqMask; return (Rnode); } - - -/******************************************************************************* - * - * FUNCTION: RsDoMemory24Descriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "Memory24" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoMemory24Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); - - Descriptor = Rnode->Buffer; - Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; - Descriptor->Memory24.ResourceLength = 9; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Read/Write type */ - - RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0); - break; - - case 1: /* Min Address */ - - Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); - break; - - case 2: /* Max Address */ - - Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); - break; - - case 3: /* Alignment */ - - Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment)); - break; - - case 4: /* Length */ - - Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); - break; - - case 5: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoMemory32Descriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "Memory32" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoMemory32Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); - - Descriptor = Rnode->Buffer; - Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; - Descriptor->Memory32.ResourceLength = 17; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Read/Write type */ - - RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0); - break; - - case 1: /* Min Address */ - - Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); - break; - - case 2: /* Max Address */ - - Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); - break; - - case 3: /* Alignment */ - - Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); - break; - - case 4: /* Length */ - - Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); - break; - - case 5: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoMemory32FixedDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "Memory32Fixed" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoMemory32FixedDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); - - Descriptor = Rnode->Buffer; - Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; - Descriptor->FixedMemory32.ResourceLength = 9; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Read/Write type */ - - RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0); - break; - - case 1: /* Address */ - - Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address)); - break; - - case 2: /* Length */ - - Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength)); - break; - - case 3: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoStartDependentDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "StartDependentFn" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoStartDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - ASL_RESOURCE_NODE *PreviousRnode; - ASL_RESOURCE_NODE *NextRnode; - UINT32 i; - UINT8 State; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); - - PreviousRnode = Rnode; - Descriptor = Rnode->Buffer; - - /* Descriptor has priority byte */ - - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - (ASL_RDESC_ST_DEPEND_SIZE + 0x01); - - /* Process all child initialization nodes */ - - State = ACPI_RSTATE_START_DEPENDENT; - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Compatibility Priority */ - - if ((UINT8) InitializerOp->Asl.Value.Integer > 2) - { - AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, - InitializerOp, NULL); - } - - RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0); - break; - - case 1: /* Performance/Robustness Priority */ - - if ((UINT8) InitializerOp->Asl.Value.Integer > 2) - { - AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, - InitializerOp, NULL); - } - - RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0); - break; - - default: - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); - - /* - * Update current byte offset to indicate the number of bytes from the - * start of the buffer. Buffer can include multiple descriptors, we - * must keep track of the offset of not only each descriptor, but each - * element (field) within each descriptor as well. - */ - - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, - NextRnode); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoStartDependentNoPriDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoStartDependentNoPriDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - ASL_RESOURCE_NODE *PreviousRnode; - ASL_RESOURCE_NODE *NextRnode; - UINT8 State; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); - - Descriptor = Rnode->Buffer; - Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | - ASL_RDESC_ST_DEPEND_SIZE; - PreviousRnode = Rnode; - - /* Process all child initialization nodes */ - - State = ACPI_RSTATE_START_DEPENDENT; - while (InitializerOp) - { - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); - - /* - * Update current byte offset to indicate the number of bytes from the - * start of the buffer. Buffer can include multiple descriptors, we - * must keep track of the offset of not only each descriptor, but each - * element (field) within each descriptor as well. - */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoVendorSmallDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "VendorShort" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoVendorSmallDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *VendorData; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - - /* Allocate worst case - 7 vendor bytes */ - - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); - - Descriptor = Rnode->Buffer; - Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; - VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); - - /* Process all child initialization nodes */ - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - for (i = 0; InitializerOp; i++) - { - if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) - { - break; - } - - /* Maximum 7 vendor data bytes allowed (0-6) */ - - if (i >= 7) - { - AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL); - - /* Eat the excess initializers */ - - while (InitializerOp) - { - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - break; - } - - VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer; - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Adjust the Rnode buffer size, so correct number of bytes are emitted */ - - Rnode->BufferLength -= (7 - i); - - /* Set the length in the Type Tag */ - - Descriptor->VendorSmall.DescriptorType |= (UINT8) i; - return (Rnode); -} - - diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype2.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype2.c index 7074a5576e..7b3d869d54 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype2.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslrestype2 - Long (type2) resource templates and descriptors + * Module Name: aslrestype2 - Miscellaneous Large resource descriptors * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,2147 +117,22 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "amlcode.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslrestype2") -/* Local prototypes */ - -static UINT16 -RsGetStringDataLength ( - ACPI_PARSE_OBJECT *InitializerOp); - - -/******************************************************************************* - * - * FUNCTION: RsGetStringDataLength - * - * PARAMETERS: InitializerOp - Start of a subtree of init nodes - * - * RETURN: Valid string length if a string node is found (otherwise 0) - * - * DESCRIPTION: In a list of peer nodes, find the first one that contains a - * string and return the length of the string. - * - ******************************************************************************/ - -static UINT16 -RsGetStringDataLength ( - ACPI_PARSE_OBJECT *InitializerOp) -{ - - while (InitializerOp) - { - if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) - { - return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); - } - InitializerOp = ASL_GET_PEER_NODE (InitializerOp); - } - - return 0; -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "DwordIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT8 *OptionalFields; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Found a valid ResourceSourceIndex */ - - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - /* Found a valid ResourceSource */ - - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "DwordMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 14: /* Address Range */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3); - break; - - case 15: /* Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "DwordSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->Address32.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address32.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, - InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; - - case 10: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 11: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 12: /* Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4); - break; - - case 13: /* Translation Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; - - case 11: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 13: /* Address Range */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3); - break; - - case 14: /* Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->ExtAddress64.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->ExtAddress64.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; - - case 11: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 14: /* Address Range */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3); - break; - - case 15: /* Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->Address64.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address64.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoWordIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "WordIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoWordBusNumberDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "WordBusNumber" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 4: /* Address Granularity */ - - Descriptor->Address16.Granularity = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 5: /* Min Address */ - - Descriptor->Address16.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 6: /* Max Address */ - - Descriptor->Address16.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; - - case 7: /* Translation Offset */ - - Descriptor->Address16.TranslationOffset = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); - break; - - case 8: /* Address Length */ - - Descriptor->Address16.AddressLength = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); - break; - - case 9: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 10: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 11: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; - return (Rnode); -} - +/* + * This module contains miscellaneous large resource descriptors: + * + * Register + * Interrupt + * VendorLong + */ /******************************************************************************* * - * FUNCTION: RsDoWordSpaceDescriptor + * FUNCTION: RsDoGeneralRegisterDescriptor * * PARAMETERS: Op - Parent resource descriptor parse node * CurrentByteOffset - Offset into the resource template AML @@ -2265,42 +140,27 @@ RsDoWordBusNumberDescriptor ( * * RETURN: Completed resource node * - * DESCRIPTION: Construct a long "WordSpace" descriptor + * DESCRIPTION: Construct a long "Register" descriptor * ******************************************************************************/ ASL_RESOURCE_NODE * -RsDoWordSpaceDescriptor ( +RsDoGeneralRegisterDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; UINT32 i; - BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); + Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER; + Descriptor->GenericReg.ResourceLength = 12; /* Process all child initialization nodes */ @@ -2308,133 +168,48 @@ RsDoWordSpaceDescriptor ( { switch (i) { - case 0: /* Resource Type */ - - Descriptor->Address16.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address16.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address16.Granularity = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address16.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 8: /* Max Address */ + case 0: /* Address space */ - Descriptor->Address16.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; + Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId)); + break; - case 9: /* Translation Offset */ + case 1: /* Register Bit Width */ - Descriptor->Address16.TranslationOffset = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth)); break; - case 10: /* Address Length */ + case 2: /* Register Bit Offset */ - Descriptor->Address16.AddressLength = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset)); break; - case 11: /* ResSourceIndex [Optional Field - BYTE] */ + case 3: /* Register Address */ - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } + Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address)); break; - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ + case 4: /* Access Size (ACPI 3.0) */ - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } + Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) + if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD) { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE, InitializerOp, NULL); } -#endif break; - case 13: /* ResourceTag */ + case 5: /* ResourceTag (ACPI 3.0b) */ UtAttachNamepathToOwner (Op, InitializerOp); break; @@ -2447,9 +222,6 @@ RsDoWordSpaceDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; return (Rnode); } @@ -2760,95 +532,3 @@ RsDoVendorLargeDescriptor ( return (Rnode); } - - -/******************************************************************************* - * - * FUNCTION: RsDoGeneralRegisterDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "Register" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); - - Descriptor = Rnode->Buffer; - Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER; - Descriptor->GenericReg.ResourceLength = 12; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Address space */ - - Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId)); - break; - - case 1: /* Register Bit Width */ - - Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth)); - break; - - case 2: /* Register Bit Offset */ - - Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset)); - break; - - case 3: /* Register Address */ - - Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address)); - break; - - case 4: /* Access Size (ACPI 3.0) */ - - Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); - break; - - case 5: /* ResourceTag (ACPI 3.0b) */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - return (Rnode); -} - - diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype2d.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype2d.c new file mode 100644 index 0000000000..dc2482d323 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype2d.c @@ -0,0 +1,814 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2d - Large DWord address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "aslcompiler.h" +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2d") + +/* + * This module contains the Dword (32-bit) address space descriptors: + * + * DwordIO + * DwordMemory + * DwordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoDwordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT8 *OptionalFields; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Found a valid ResourceSourceIndex */ + + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + /* Found a valid ResourceSource */ + + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address32.Minimum, + (UINT64) Descriptor->Address32.Maximum, + (UINT64) Descriptor->Address32.AddressLength, + (UINT64) Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoDwordMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 14: /* Address Range */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3); + break; + + case 15: /* Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address32.Minimum, + (UINT64) Descriptor->Address32.Maximum, + (UINT64) Descriptor->Address32.AddressLength, + (UINT64) Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoDwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address32.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address32.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, + InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address32.Minimum, + (UINT64) Descriptor->Address32.Maximum, + (UINT64) Descriptor->Address32.AddressLength, + (UINT64) Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype2e.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype2e.c new file mode 100644 index 0000000000..89da9338cb --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype2e.c @@ -0,0 +1,645 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2e - Large Extended address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "aslcompiler.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2e") + +/* + * This module contains the Extended (64-bit) address space descriptors: + * + * ExtendedIO + * ExtendedMemory + * ExtendedSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 11: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 12: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4); + break; + + case 13: /* Translation Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 13: /* Address Range */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3); + break; + + case 14: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->ExtAddress64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->ExtAddress64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype2q.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype2q.c new file mode 100644 index 0000000000..e652890722 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype2q.c @@ -0,0 +1,793 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2q - Large QWord address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "aslcompiler.h" +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2q") + +/* + * This module contains the QWord (64-bit) address space descriptors: + * + * QWordIO + * QWordMemory + * QWordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoQwordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoQwordMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 14: /* Address Range */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3); + break; + + case 15: /* Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoQwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/aslrestype2w.c b/sys/contrib/dev/acpica-unix/compiler/aslrestype2w.c new file mode 100644 index 0000000000..c9d98fe851 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/aslrestype2w.c @@ -0,0 +1,774 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2w - Large Word address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "aslcompiler.h" +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2w") + +/* + * This module contains the Word (16-bit) address space descriptors: + * + * WordIO + * WordMemory + * WordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoWordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address16.Minimum, + (UINT64) Descriptor->Address16.Maximum, + (UINT64) Descriptor->Address16.AddressLength, + (UINT64) Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoWordBusNumberDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordBusNumber" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordBusNumberDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 4: /* Address Granularity */ + + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 5: /* Min Address */ + + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 6: /* Max Address */ + + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 7: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 8: /* Address Length */ + + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 9: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 10: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 11: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address16.Minimum, + (UINT64) Descriptor->Address16.Maximum, + (UINT64) Descriptor->Address16.AddressLength, + (UINT64) Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoWordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address16.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address16.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + (UINT64) Descriptor->Address16.Minimum, + (UINT64) Descriptor->Address16.Maximum, + (UINT64) Descriptor->Address16.AddressLength, + (UINT64) Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp, Op); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/aslstartup.c b/sys/contrib/dev/acpica-unix/compiler/aslstartup.c index 87e102bd9e..6c3ba54619 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslstartup.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,22 +124,21 @@ #define ASL_MAX_FILES 256 -char *FileList[ASL_MAX_FILES]; -int FileCount; -BOOLEAN AslToFile = TRUE; +static char *FileList[ASL_MAX_FILES]; +static BOOLEAN AslToFile = TRUE; /* Local prototypes */ -static void -AslInitializeGlobals ( - void); - static char ** AsDoWildcard ( char *DirectoryPathname, char *FileSpecifier); +static UINT8 +AslDetectSourceFileType ( + ASL_FILE_INFO *Info); + /******************************************************************************* * @@ -154,7 +153,7 @@ AsDoWildcard ( * ******************************************************************************/ -static void +void AslInitializeGlobals ( void) { @@ -167,10 +166,13 @@ AslInitializeGlobals ( Gbl_CurrentLineNumber = 1; Gbl_LogicalLineNumber = 1; Gbl_CurrentLineOffset = 0; + Gbl_InputFieldCount = 0; Gbl_LineBufPtr = Gbl_CurrentLineBuffer; Gbl_ErrorLog = NULL; Gbl_NextError = NULL; + Gbl_Signature = NULL; + Gbl_FileType = 0; AslGbl_NextEvent = 0; for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++) @@ -179,6 +181,10 @@ AslInitializeGlobals ( } Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = NULL; + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle = NULL; + + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename = NULL; + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL; } @@ -203,6 +209,7 @@ AsDoWildcard ( #ifdef WIN32 void *DirInfo; char *Filename; + int FileCount; FileCount = 0; @@ -257,6 +264,77 @@ AsDoWildcard ( } +/******************************************************************************* + * + * FUNCTION: AslDetectSourceFileType + * + * PARAMETERS: Info - Name/Handle for the file (must be open) + * + * RETURN: File Type + * + * DESCRIPTION: Determine the type of the input file. Either binary (contains + * non-ASCII characters), ASL file, or an ACPI Data Table file. + * + ******************************************************************************/ + +static UINT8 +AslDetectSourceFileType ( + ASL_FILE_INFO *Info) +{ + char *FileChar; + UINT8 Type; + ACPI_STATUS Status; + + + /* Check for 100% ASCII source file (comments are ignored) */ + + Status = FlCheckForAscii (Info); + if (ACPI_FAILURE (Status)) + { + printf ("Non-ascii input file - %s\n", Info->Filename); + Type = ASL_INPUT_TYPE_BINARY; + goto Cleanup; + } + + /* + * File is ASCII. Determine if this is an ASL file or an ACPI data + * table file. + */ + while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle)) + { + /* Uppercase the buffer for caseless compare */ + + FileChar = Gbl_CurrentLineBuffer; + while (*FileChar) + { + *FileChar = (char) toupper ((int) *FileChar); + FileChar++; + } + + /* Presence of "DefinitionBlock" indicates actual ASL code */ + + if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) + { + /* Appears to be an ASL file */ + + Type = ASL_INPUT_TYPE_ASCII_ASL; + goto Cleanup; + } + } + + /* Not an ASL source file, default to a data table source file */ + + Type = ASL_INPUT_TYPE_ASCII_DATA; + +Cleanup: + + /* Must seek back to the start of the file */ + + fseek (Info->Handle, 0, SEEK_SET); + return (Type); +} + + /******************************************************************************* * * FUNCTION: AslDoOneFile @@ -287,7 +365,7 @@ AslDoOneFile ( */ if (Gbl_DisasmFlag || Gbl_GetAllTables) { - /* ACPI CA subsystem initialization */ + /* ACPICA subsystem initialization */ Status = AdInitialize (); if (ACPI_FAILURE (Status)) @@ -319,7 +397,7 @@ AslDoOneFile ( /* Shutdown compiler and ACPICA subsystem */ AeClearErrorLog (); - AcpiTerminate (); + (void) AcpiTerminate (); /* * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the @@ -330,23 +408,77 @@ AslDoOneFile ( AcpiOsPrintf ("\nCompiling \"%s\"\n", Gbl_Files[ASL_FILE_INPUT].Filename); } + else + { + Gbl_Files[ASL_FILE_INPUT].Filename = NULL; + return (AE_OK); + } } /* - * ASL Compilation (Optional) + * Open the input file. Here, this should be an ASCII source file, + * either an ASL file or a Data Table file */ - if (Gbl_DoCompile) + Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); + if (ACPI_FAILURE (Status)) { - /* - * If -p not specified, we will use the input filename as the - * output filename prefix - */ - if (Gbl_UseDefaultAmlFilename) + AePrintErrorLog (ASL_FILE_STDERR); + return (AE_ERROR); + } + + /* Determine input file type */ + + Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]); + if (Gbl_FileType == ASL_INPUT_TYPE_BINARY) + { + return (AE_ERROR); + } + + /* + * If -p not specified, we will use the input filename as the + * output filename prefix + */ + if (Gbl_UseDefaultAmlFilename) + { + Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename; + } + + /* Open the optional output files (listings, etc.) */ + + Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); + if (ACPI_FAILURE (Status)) + { + AePrintErrorLog (ASL_FILE_STDERR); + return (AE_ERROR); + } + + /* + * Compilation of ASL source versus DataTable source uses different + * compiler subsystems + */ + switch (Gbl_FileType) + { + /* + * Data Table Compilation + */ + case ASL_INPUT_TYPE_ASCII_DATA: + + Status = DtDoCompile (); + + if (Gbl_Signature) { - Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename; + ACPI_FREE (Gbl_Signature); + Gbl_Signature = NULL; } + AeClearErrorLog (); + return (Status); + + /* + * ASL Compilation (Optional) + */ + case ASL_INPUT_TYPE_ASCII_ASL: - /* ACPI CA subsystem initialization (Must be re-initialized) */ + /* ACPICA subsystem initialization */ Status = AdInitialize (); if (ACPI_FAILURE (Status)) @@ -355,7 +487,7 @@ AslDoOneFile ( } Status = CmDoCompile (); - AcpiTerminate (); + (void) AcpiTerminate (); /* * Return non-zero exit code if there have been errors, unless the @@ -367,9 +499,17 @@ AslDoOneFile ( } AeClearErrorLog (); - } + return (AE_OK); + + case ASL_INPUT_TYPE_BINARY: - return (AE_OK); + AePrintErrorLog (ASL_FILE_STDERR); + return (AE_ERROR); + + default: + printf ("Unknown file type %X\n", Gbl_FileType); + return (AE_ERROR); + } } @@ -389,10 +529,11 @@ AslDoOneFile ( ACPI_STATUS AslDoOnePathname ( - char *Pathname) + char *Pathname, + ASL_PATHNAME_CALLBACK PathCallback) { - ACPI_STATUS Status; - char **FileList; + ACPI_STATUS Status = AE_OK; + char **WildcardList; char *Filename; char *FullPathname; @@ -407,16 +548,16 @@ AslDoOnePathname ( /* Expand possible wildcard into a file list (Windows/DOS only) */ - FileList = AsDoWildcard (Gbl_DirectoryPath, Filename); - while (*FileList) + WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename); + while (*WildcardList) { FullPathname = ACPI_ALLOCATE ( - strlen (Gbl_DirectoryPath) + strlen (*FileList) + 1); + strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1); /* Construct a full path to the file */ strcpy (FullPathname, Gbl_DirectoryPath); - strcat (FullPathname, *FileList); + strcat (FullPathname, *WildcardList); /* * If -p not specified, we will use the input filename as the @@ -427,20 +568,18 @@ AslDoOnePathname ( Gbl_OutputFilenamePrefix = FullPathname; } - Status = AslDoOneFile (FullPathname); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* Save status from all compiles */ + + Status |= (*PathCallback) (FullPathname); ACPI_FREE (FullPathname); - ACPI_FREE (*FileList); - *FileList = NULL; - FileList++; + ACPI_FREE (*WildcardList); + *WildcardList = NULL; + WildcardList++; } ACPI_FREE (Gbl_DirectoryPath); ACPI_FREE (Filename); - return (AE_OK); + return (Status); } diff --git a/sys/contrib/dev/acpica-unix/compiler/aslstubs.c b/sys/contrib/dev/acpica-unix/compiler/aslstubs.c index cb822e57eb..4f57e35e5d 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslstubs.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +119,7 @@ #include "actables.h" #include "acevents.h" #include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslstubs") @@ -136,6 +137,12 @@ AeLocalGetRootPointer ( return 0; } +void +AcpiNsExecModuleCodeList ( + void) +{ +} + ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address, @@ -236,11 +243,13 @@ AcpiEvInitializeRegion ( return (AE_OK); } -ACPI_STATUS -AcpiEvCheckForWakeOnlyGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) +void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) { - return (AE_OK); + return; } ACPI_STATUS @@ -269,7 +278,6 @@ AcpiExLoadTableOp ( return (AE_SUPPORT); } - ACPI_STATUS AcpiExUnloadTable ( ACPI_OPERAND_OBJECT *DdbHandle) diff --git a/sys/contrib/dev/acpica-unix/compiler/asltransform.c b/sys/contrib/dev/acpica-unix/compiler/asltransform.c index eb4546818c..b5890406f3 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asltransform.c +++ b/sys/contrib/dev/acpica-unix/compiler/asltransform.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -468,6 +468,8 @@ TrDoSwitch ( ACPI_PARSE_OBJECT *NewOp; ACPI_PARSE_OBJECT *NewOp2; ACPI_PARSE_OBJECT *MethodOp; + ACPI_PARSE_OBJECT *StoreOp; + ACPI_PARSE_OBJECT *BreakOp; char *PredicateValueName; UINT16 Index; UINT32 Btype; @@ -552,7 +554,7 @@ TrDoSwitch ( NewOp = NewOp2; NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); NewOp->Asl.Next = NewOp2; TrAmlInitLineNumbers (NewOp2, Predicate); @@ -610,7 +612,7 @@ TrDoSwitch ( * CaseOp->Child->Peer is the beginning of the case block */ NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); NewOp->Asl.Next = Predicate; TrAmlInitLineNumbers (NewOp, Predicate); @@ -638,11 +640,7 @@ TrDoSwitch ( */ if (CurrentParentNode == StartNode) { - Conditional->Asl.Parent = CurrentParentNode->Asl.Parent; - - /* Link IF into the peer list */ - - TrAmlInsertPeer (CurrentParentNode, Conditional); + Conditional->Asl.Next = NULL; } else { @@ -676,7 +674,7 @@ TrDoSwitch ( { /* Unknown peer opcode */ - AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%d)\n", + AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%u)\n", Next->Asl.ParseOpName, Next->Asl.ParseOpcode); } } @@ -695,6 +693,7 @@ TrDoSwitch ( { return; } + TrAmlInitNode (DefaultOp, PARSEOP_ELSE); DefaultOp->Asl.Parent = Conditional->Asl.Parent; @@ -762,7 +761,7 @@ TrDoSwitch ( /* Create the NameSeg child for the Name node */ NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION; NewOp->Asl.Child = NewOp2; @@ -772,22 +771,22 @@ TrDoSwitch ( { case ACPI_BTYPE_INTEGER: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO, - (ACPI_INTEGER) 0); + (UINT64) 0); break; case ACPI_BTYPE_STRING: NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, - (ACPI_INTEGER) ACPI_TO_INTEGER ("")); + (UINT64) ACPI_TO_INTEGER ("")); break; case ACPI_BTYPE_BUFFER: (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER, - (ACPI_INTEGER) 0)); + (UINT64) 0)); Next = NewOp2->Asl.Next; (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO, - (ACPI_INTEGER) 1)); + (UINT64) 1)); (void) TrLinkPeerNode (Next->Asl.Child, - TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (ACPI_INTEGER) 0)); + TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (UINT64) 0)); TrAmlSetSubtreeParent (Next->Asl.Child, Next); break; @@ -799,22 +798,44 @@ TrDoSwitch ( TrAmlSetSubtreeParent (NewOp2, NewOp); /* - * Transform the Switch() into a Store() node which will be used to save the + * Transform the Switch() into a While(One)-Break node. + * And create a Store() node which will be used to save the * Switch() value. The store is of the form: Store (Value, _T_x) * where _T_x is the temp variable. */ - TrAmlInitNode (StartNode, PARSEOP_STORE); - StartNode->Asl.Child = NULL; + TrAmlInitNode (StartNode, PARSEOP_WHILE); + NewOp = TrCreateLeafNode (PARSEOP_ONE); + NewOp->Asl.Next = Predicate->Asl.Next; + NewOp->Asl.Parent = StartNode; + StartNode->Asl.Child = NewOp; + + /* Create a Store() node */ + + StoreOp = TrCreateLeafNode (PARSEOP_STORE); + StoreOp->Asl.Parent = StartNode; + TrAmlInsertPeer (NewOp, StoreOp); /* Complete the Store subtree */ - StartNode->Asl.Child = Predicate; - Predicate->Asl.Parent = StartNode; + StoreOp->Asl.Child = Predicate; + Predicate->Asl.Parent = StoreOp; NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); - NewOp->Asl.Parent = StartNode; + (UINT64) ACPI_TO_INTEGER (PredicateValueName)); + NewOp->Asl.Parent = StoreOp; Predicate->Asl.Next = NewOp; + + /* Create a Break() node and insert it into the end of While() */ + + Conditional = StartNode->Asl.Child; + while (Conditional->Asl.Next) + { + Conditional = Conditional->Asl.Next; + } + + BreakOp = TrCreateLeafNode (PARSEOP_BREAK); + BreakOp->Asl.Parent = StartNode; + TrAmlInsertPeer (Conditional, BreakOp); } diff --git a/sys/contrib/dev/acpica-unix/compiler/asltree.c b/sys/contrib/dev/acpica-unix/compiler/asltree.c index 30f59ee46d..88b33c3fa3 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asltree.c +++ b/sys/contrib/dev/acpica-unix/compiler/asltree.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +117,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asltree") @@ -466,13 +467,82 @@ TrCreateLeafNode ( Op = TrAllocateNode (ParseOpcode); DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateLeafNode Ln/Col %d/%d NewNode %p Op %s\n\n", + "\nCreateLeafNode Ln/Col %u/%u NewNode %p Op %s\n\n", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode)); return Op; } +/******************************************************************************* + * + * FUNCTION: TrCreateConstantLeafNode + * + * PARAMETERS: ParseOpcode - The constant opcode + * + * RETURN: Pointer to the new node. Aborts on allocation failure + * + * DESCRIPTION: Create a leaf node (no children or peers) for one of the + * special constants - __LINE__, __FILE__, and __DATE__. + * + * Note: An implemenation of __FUNC__ cannot happen here because we don't + * have a full parse tree at this time and cannot find the parent control + * method. If it is ever needed, __FUNC__ must be implemented later, after + * the parse tree has been fully constructed. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +TrCreateConstantLeafNode ( + UINT32 ParseOpcode) +{ + ACPI_PARSE_OBJECT *Op = NULL; + time_t CurrentTime; + char *StaticTimeString; + char *TimeString; + + + switch (ParseOpcode) + { + case PARSEOP___LINE__: + Op = TrAllocateNode (PARSEOP_INTEGER); + Op->Asl.Value.Integer = Op->Asl.LineNumber; + break; + + case PARSEOP___FILE__: + Op = TrAllocateNode (PARSEOP_STRING_LITERAL); + + /* Op.Asl.Filename contains the full pathname to the file */ + + Op->Asl.Value.String = Op->Asl.Filename; + break; + + case PARSEOP___DATE__: + Op = TrAllocateNode (PARSEOP_STRING_LITERAL); + + /* Get a copy of the current time */ + + CurrentTime = time (NULL); + StaticTimeString = ctime (&CurrentTime); + TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1); + strcpy (TimeString, StaticTimeString); + + TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */ + Op->Asl.Value.String = TimeString; + break; + + default: /* This would be an internal error */ + return (NULL); + } + + DbgPrint (ASL_PARSE_OUTPUT, + "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ", + Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode), + ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + return (Op); +} + + /******************************************************************************* * * FUNCTION: TrCreateValuedLeafNode @@ -490,7 +560,7 @@ TrCreateLeafNode ( ACPI_PARSE_OBJECT * TrCreateValuedLeafNode ( UINT32 ParseOpcode, - ACPI_INTEGER Value) + UINT64 Value) { ACPI_PARSE_OBJECT *Op; @@ -498,7 +568,7 @@ TrCreateValuedLeafNode ( Op = TrAllocateNode (ParseOpcode); DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateValuedLeafNode Ln/Col %d/%d NewNode %p Op %s Value %8.8X%8.8X ", + "\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode), ACPI_FORMAT_UINT64 (Value)); Op->Asl.Value.Integer = Value; @@ -575,7 +645,7 @@ TrCreateNode ( Op = TrAllocateNode (ParseOpcode); DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateNode Ln/Col %d/%d NewParent %p Child %d Op %s ", + "\nCreateNode Ln/Col %u/%u NewParent %p Child %u Op %s ", Op->Asl.LineNumber, Op->Asl.Column, Op, NumChildren, UtGetOpName(ParseOpcode)); /* Some extra debug output based on the parse opcode */ @@ -694,7 +764,7 @@ TrLinkChildren ( TrSetEndLineNumber (Op); DbgPrint (ASL_PARSE_OUTPUT, - "\nLinkChildren Line [%d to %d] NewParent %p Child %d Op %s ", + "\nLinkChildren Line [%u to %u] NewParent %p Child %u Op %s ", Op->Asl.LineNumber, Op->Asl.EndLine, Op, NumChildren, UtGetOpName(Op->Asl.ParseOpcode)); @@ -882,7 +952,7 @@ TrLinkPeerNodes ( DbgPrint (ASL_PARSE_OUTPUT, - "\nLinkPeerNodes: (%d) ", NumPeers); + "\nLinkPeerNodes: (%u) ", NumPeers); va_start (ap, NumPeers); This = va_arg (ap, ACPI_PARSE_OBJECT *); @@ -893,7 +963,7 @@ TrLinkPeerNodes ( */ for (i = 0; i < (NumPeers -1); i++) { - DbgPrint (ASL_PARSE_OUTPUT, "%d=%p ", (i+1), This); + DbgPrint (ASL_PARSE_OUTPUT, "%u=%p ", (i+1), This); while (This->Asl.Next) { diff --git a/sys/contrib/dev/acpica-unix/compiler/asltypes.h b/sys/contrib/dev/acpica-unix/compiler/asltypes.h index 6b3c4243bb..1046365dfe 100644 --- a/sys/contrib/dev/acpica-unix/compiler/asltypes.h +++ b/sys/contrib/dev/acpica-unix/compiler/asltypes.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -188,21 +188,6 @@ typedef struct asl_mapping_entry } ASL_MAPPING_ENTRY; -/* An entry in the Reserved Name information table */ - -#define ASL_RSVD_RETURN_VALUE 0x01 -#define ASL_RSVD_RESOURCE_NAME 0x02 -#define ASL_RSVD_SCOPE 0x04 - -typedef struct asl_reserved_info -{ - char *Name; - UINT8 NumArguments; - UINT8 Flags; - -} ASL_RESERVED_INFO; - - /* Parse tree walk info structure */ typedef struct asl_walk_info @@ -255,6 +240,14 @@ typedef enum #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +typedef struct asl_include_dir +{ + char *Dir; + struct asl_include_dir *Next; + +} ASL_INCLUDE_DIR; + + /* An entry in the exception list, one for each error/warning */ typedef struct asl_error_msg @@ -286,11 +279,17 @@ typedef struct asl_listing_node /* Callback interface for a parse tree walk */ +/* + * TBD - another copy of this is in adisasm.h, fix + */ +#ifndef ASL_WALK_CALLBACK_DEFINED typedef ACPI_STATUS (*ASL_WALK_CALLBACK) ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); +#define ASL_WALK_CALLBACK_DEFINED +#endif typedef struct asl_event_info @@ -303,269 +302,4 @@ typedef struct asl_event_info } ASL_EVENT_INFO; -#define ASL_WARNING 0 -#define ASL_WARNING2 1 -#define ASL_WARNING3 2 -#define ASL_ERROR 3 -#define ASL_REMARK 4 -#define ASL_OPTIMIZATION 5 -#define ASL_NUM_REPORT_LEVELS 6 - - -typedef enum -{ - ASL_MSG_RESERVED = 0, - ASL_MSG_ALPHANUMERIC_STRING, - ASL_MSG_AML_NOT_IMPLEMENTED, - ASL_MSG_ARG_COUNT_HI, - ASL_MSG_ARG_COUNT_LO, - ASL_MSG_ARG_INIT, - ASL_MSG_BACKWARDS_OFFSET, - ASL_MSG_BITS_TO_BYTES, - ASL_MSG_BUFFER_LENGTH, - ASL_MSG_BYTES_TO_BITS, - ASL_MSG_CLOSE, - ASL_MSG_COMPILER_INTERNAL, - ASL_MSG_CONSTANT_EVALUATION, - ASL_MSG_CONSTANT_FOLDED, - ASL_MSG_CORE_EXCEPTION, - ASL_MSG_DEBUG_FILE_OPEN, - ASL_MSG_DEBUG_FILENAME, - ASL_MSG_DEPENDENT_NESTING, - ASL_MSG_DMA_CHANNEL, - ASL_MSG_DMA_LIST, - ASL_MSG_DUPLICATE_CASE, - ASL_MSG_DUPLICATE_ITEM, - ASL_MSG_EARLY_EOF, - ASL_MSG_ENCODING_LENGTH, - ASL_MSG_EX_INTERRUPT_LIST, - ASL_MSG_EX_INTERRUPT_LIST_MIN, - ASL_MSG_EX_INTERRUPT_NUMBER, - ASL_MSG_FIELD_ACCESS_WIDTH, - ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, - ASL_MSG_FIELD_UNIT_OFFSET, - ASL_MSG_INCLUDE_FILE_OPEN, - ASL_MSG_INPUT_FILE_OPEN, - ASL_MSG_INTEGER_LENGTH, - ASL_MSG_INTEGER_OPTIMIZATION, - ASL_MSG_INTERRUPT_LIST, - ASL_MSG_INTERRUPT_NUMBER, - ASL_MSG_INVALID_CONSTANT_OP, - ASL_MSG_INVALID_EISAID, - ASL_MSG_INVALID_ESCAPE, - ASL_MSG_INVALID_OPERAND, - ASL_MSG_INVALID_PERFORMANCE, - ASL_MSG_INVALID_PRIORITY, - ASL_MSG_INVALID_STRING, - ASL_MSG_INVALID_TARGET, - ASL_MSG_INVALID_TIME, - ASL_MSG_INVALID_TYPE, - ASL_MSG_INVALID_UUID, - ASL_MSG_LIST_LENGTH, - ASL_MSG_LISTING_FILE_OPEN, - ASL_MSG_LISTING_FILENAME, - ASL_MSG_LOCAL_INIT, - ASL_MSG_LONG_LINE, - ASL_MSG_MEMORY_ALLOCATION, - ASL_MSG_MISSING_ENDDEPENDENT, - ASL_MSG_MISSING_STARTDEPENDENT, - ASL_MSG_MULTIPLE_TYPES, - ASL_MSG_NAME_EXISTS, - ASL_MSG_NAME_OPTIMIZATION, - ASL_MSG_NESTED_COMMENT, - ASL_MSG_NO_CASES, - ASL_MSG_NO_RETVAL, - ASL_MSG_NO_WHILE, - ASL_MSG_NON_ASCII, - ASL_MSG_NOT_EXIST, - ASL_MSG_NOT_FOUND, - ASL_MSG_NOT_METHOD, - ASL_MSG_NOT_PARAMETER, - ASL_MSG_NOT_REACHABLE, - ASL_MSG_OPEN, - ASL_MSG_OUTPUT_FILE_OPEN, - ASL_MSG_OUTPUT_FILENAME, - ASL_MSG_PACKAGE_LENGTH, - ASL_MSG_READ, - ASL_MSG_RECURSION, - ASL_MSG_REGION_BUFFER_ACCESS, - ASL_MSG_REGION_BYTE_ACCESS, - ASL_MSG_RESERVED_ARG_COUNT_HI, - ASL_MSG_RESERVED_ARG_COUNT_LO, - ASL_MSG_RESERVED_METHOD, - ASL_MSG_RESERVED_OPERAND_TYPE, - ASL_MSG_RESERVED_RETURN_VALUE, - ASL_MSG_RESERVED_USE, - ASL_MSG_RESERVED_WORD, - ASL_MSG_RESOURCE_FIELD, - ASL_MSG_RESOURCE_INDEX, - ASL_MSG_RESOURCE_LIST, - ASL_MSG_RESOURCE_SOURCE, - ASL_MSG_RETURN_TYPES, - ASL_MSG_SCOPE_FWD_REF, - ASL_MSG_SCOPE_TYPE, - ASL_MSG_SEEK, - ASL_MSG_SINGLE_NAME_OPTIMIZATION, - ASL_MSG_SOME_NO_RETVAL, - ASL_MSG_SWITCH_TYPE, - ASL_MSG_SYNC_LEVEL, - ASL_MSG_SYNTAX, - ASL_MSG_TABLE_SIGNATURE, - ASL_MSG_TOO_MANY_TEMPS, - ASL_MSG_UNKNOWN_RESERVED_NAME, - ASL_MSG_UNREACHABLE_CODE, - ASL_MSG_UNSUPPORTED, - ASL_MSG_VENDOR_LIST, - ASL_MSG_WRITE, - ASL_MSG_MULTIPLE_DEFAULT, - ASL_MSG_TIMEOUT, - ASL_MSG_RESULT_NOT_USED, - ASL_MSG_NOT_REFERENCED, - ASL_MSG_NON_ZERO, - ASL_MSG_STRING_LENGTH, - ASL_MSG_SERIALIZED, - ASL_MSG_COMPILER_RESERVED, - ASL_MSG_NAMED_OBJECT_IN_WHILE, - ASL_MSG_LOCAL_OUTSIDE_METHOD - -} ASL_MESSAGE_IDS; - -#ifdef ASL_EXCEPTIONS - -char *AslMessages [] = { -/* The zeroth message is resesrved */ "", -/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", -/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", -/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", -/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", -/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", -/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", -/* ASL_MSG_BITS_TO_BYTES */ "Field offset is in bits, but a byte offset is required", -/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", -/* ASL_MSG_BYTES_TO_BITS */ "Field offset is in bytes, but a bit offset is required", -/* ASL_MSG_CLOSE */ "Could not close file", -/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", -/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", -/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", -/* ASL_MSG_CORE_EXCEPTION */ "From ACPI CA Subsystem", -/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", -/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", -/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",\ -/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", -/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", -/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", -/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", -/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", -/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", -/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", -/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", -/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", -/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", -/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", -/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", -/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", -/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", -/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating", -/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", -/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", -/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", -/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", -/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", -/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", -/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", -/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", -/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", -/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", -/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", -/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", -/* ASL_MSG_INVALID_TYPE */ "Invalid type", -/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", -/* ASL_MSG_LIST_LENGTH */ "Initializer list too long", -/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", -/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", -/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", -/* ASL_MSG_LONG_LINE */ "Splitting long input line", -/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", -/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", -/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", -/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", -/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", -/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", -/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", -/* ASL_MSG_NO_CASES */ "No Case statements under Switch", -/* ASL_MSG_NO_RETVAL */ "Called method returns no value", -/* ASL_MSG_NO_WHILE */ "No enclosing While statement", -/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", -/* ASL_MSG_NOT_EXIST */ "Object does not exist", -/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", -/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", -/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", -/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", -/* ASL_MSG_OPEN */ "Could not open file", -/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", -/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", -/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", -/* ASL_MSG_READ */ "Could not read file", -/* ASL_MSG_RECURSION */ "Recursive method call", -/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", -/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", -/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", -/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", -/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", -/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid operand type for reserved name, must be", -/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", -/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", -/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", -/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", -/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", -/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", -/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", -/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", -/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed", -/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", -/* ASL_MSG_SEEK */ "Could not seek file", -/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", -/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", -/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", -/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", -/* ASL_MSG_SYNTAX */ "", -/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", -/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", -/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", -/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", -/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", -/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", -/* ASL_MSG_WRITE */ "Could not write file", -/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", -/* ASL_MSG_TIMEOUT */ "Possible operator timeout is ignored", -/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", -/* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", -/* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", -/* ASL_MSG_STRING_LENGTH */ "String literal too long", -/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", -/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", -/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", -/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method" - -}; - - -char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { - "Warning ", - "Warning ", - "Warning ", - "Error ", - "Remark ", - "Optimize" -}; - -#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ - -/* Exception counters */ - -UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; - -#endif - - #endif /* __ASLTYPES_H */ diff --git a/sys/contrib/dev/acpica-unix/compiler/aslutils.c b/sys/contrib/dev/acpica-unix/compiler/aslutils.c index ecba7c32cf..83d33f79e8 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslutils.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslutils.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,8 +117,10 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acdisasm.h" #include "acnamesp.h" #include "amlcode.h" +#include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslutils") @@ -130,7 +132,7 @@ static const char * const *yytname = &AslCompilername[254]; extern const char * const yytname[]; #endif -char HexLookup[] = +char AslHexLookup[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; @@ -142,7 +144,7 @@ static ACPI_STATUS UtStrtoul64 ( char *String, UINT32 Base, - ACPI_INTEGER *RetInteger); + UINT64 *RetInteger); static void UtPadNameWithUnderscores ( @@ -155,6 +157,50 @@ UtAttachNameseg ( char *Name); +/******************************************************************************* + * + * FUNCTION: UtDisplaySupportedTables + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Print all supported ACPI table names. + * + ******************************************************************************/ + +void +UtDisplaySupportedTables ( + void) +{ + ACPI_DMTABLE_DATA *TableData; + UINT32 i = 6; + + + printf ("\nACPI tables supported by iASL subsystems in " + "version %8.8X:\n" + " ASL and Data Table compilers\n" + " AML and Data Table disassemblers\n" + " ACPI table template generator\n\n", ACPI_CA_VERSION); + + /* Special tables */ + + printf ("%8u) %s %s\n", 1, ACPI_SIG_DSDT, "Differentiated System Description Table"); + printf ("%8u) %s %s\n", 2, ACPI_SIG_SSDT, "Secondary System Description Table"); + printf ("%8u) %s %s\n", 3, ACPI_SIG_FADT, "Fixed ACPI Description Table (FADT)"); + printf ("%8u) %s %s\n", 4, ACPI_SIG_FACS, "Firmware ACPI Control Structure"); + printf ("%8u) %s %s\n", 5, ACPI_RSDP_NAME, "Root System Description Pointer"); + + /* All data tables with common table header */ + + for (TableData = AcpiDmTableData; TableData->Signature; TableData++) + { + printf ("%8u) %s %s\n", i, TableData->Signature, TableData->Name); + i++; + } +} + + /******************************************************************************* * * FUNCTION: AcpiPsDisplayConstantOpcodes @@ -214,6 +260,8 @@ UtLocalCalloc ( Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, Gbl_InputByteCount, Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + + CmCleanupAndExit (); exit (1); } @@ -338,8 +386,8 @@ UtConvertByteToHex ( Buffer[0] = '0'; Buffer[1] = 'x'; - Buffer[2] = (UINT8) HexLookup[(RawByte >> 4) & 0xF]; - Buffer[3] = (UINT8) HexLookup[RawByte & 0xF]; + Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; + Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; } @@ -364,8 +412,8 @@ UtConvertByteToAsmHex ( { Buffer[0] = '0'; - Buffer[1] = (UINT8) HexLookup[(RawByte >> 4) & 0xF]; - Buffer[2] = (UINT8) HexLookup[RawByte & 0xF]; + Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; + Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; Buffer[3] = 'h'; } @@ -519,37 +567,61 @@ UtDisplaySummary ( { /* Compiler name and version number */ - FlPrintFile (FileId, "%s version %X [%s]\n", - CompilerId, (UINT32) ACPI_CA_VERSION, __DATE__); + FlPrintFile (FileId, "%s version %X%s [%s]\n", + ASL_COMPILER_NAME, (UINT32) ACPI_CA_VERSION, ACPI_WIDTH, __DATE__); } - /* Input/Output summary */ - - FlPrintFile (FileId, - "ASL Input: %s - %d lines, %d bytes, %d keywords\n", - Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, - Gbl_InputByteCount, TotalKeywords); - - /* AML summary */ + if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA) + { + FlPrintFile (FileId, + "Table Input: %s - %u lines, %u bytes, %u fields\n", + Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, + Gbl_InputByteCount, Gbl_InputFieldCount); - if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) + if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) + { + FlPrintFile (FileId, + "Binary Output: %s - %u bytes\n\n", + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength); + } + } + else { + /* Input/Output summary */ + FlPrintFile (FileId, - "AML Output: %s - %d bytes, %d named objects, %d executable opcodes\n\n", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, - TotalNamedObjects, TotalExecutableOpcodes); + "ASL Input: %s - %u lines, %u bytes, %u keywords\n", + Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, + Gbl_InputByteCount, TotalKeywords); + + /* AML summary */ + + if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) + { + FlPrintFile (FileId, + "AML Output: %s - %u bytes, %u named objects, %u executable opcodes\n\n", + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, + TotalNamedObjects, TotalExecutableOpcodes); + } } /* Error summary */ FlPrintFile (FileId, - "Compilation complete. %d Errors, %d Warnings, %d Remarks, %d Optimizations\n", + "Compilation complete. %u Errors, %u Warnings, %u Remarks", Gbl_ExceptionCount[ASL_ERROR], Gbl_ExceptionCount[ASL_WARNING] + Gbl_ExceptionCount[ASL_WARNING2] + Gbl_ExceptionCount[ASL_WARNING3], - Gbl_ExceptionCount[ASL_REMARK], - Gbl_ExceptionCount[ASL_OPTIMIZATION]); + Gbl_ExceptionCount[ASL_REMARK]); + + if (Gbl_FileType != ASL_INPUT_TYPE_ASCII_DATA) + { + FlPrintFile (FileId, + ", %u Optimizations", Gbl_ExceptionCount[ASL_OPTIMIZATION]); + } + + FlPrintFile (FileId, "\n"); } @@ -846,12 +918,12 @@ UtAttachNamepathToOwner ( * ******************************************************************************/ -ACPI_INTEGER +UINT64 UtDoConstant ( char *String) { ACPI_STATUS Status; - ACPI_INTEGER Converted; + UINT64 Converted; char ErrBuf[64]; @@ -888,11 +960,11 @@ static ACPI_STATUS UtStrtoul64 ( char *String, UINT32 Base, - ACPI_INTEGER *RetInteger) + UINT64 *RetInteger) { UINT32 Index; UINT32 Sign; - ACPI_INTEGER ReturnValue = 0; + UINT64 ReturnValue = 0; ACPI_STATUS Status = AE_OK; @@ -916,7 +988,7 @@ UtStrtoul64 ( /* Skip over any white space in the buffer: */ - while (isspace (*String) || *String == '\t') + while (isspace ((int) *String) || *String == '\t') { ++String; } @@ -948,7 +1020,7 @@ UtStrtoul64 ( { if (*String == '0') { - if (tolower (*(++String)) == 'x') + if (tolower ((int) *(++String)) == 'x') { Base = 16; ++String; @@ -975,7 +1047,7 @@ UtStrtoul64 ( if (Base == 16 && *String == '0' && - tolower (*(++String)) == 'x') + tolower ((int) *(++String)) == 'x') { String++; } @@ -984,14 +1056,14 @@ UtStrtoul64 ( while (*String) { - if (isdigit (*String)) + if (isdigit ((int) *String)) { Index = ((UINT8) *String) - '0'; } else { - Index = (UINT8) toupper (*String); - if (isupper ((char) Index)) + Index = (UINT8) toupper ((int) *String); + if (isupper ((int) Index)) { Index = Index - 'A' + 10; } @@ -1008,8 +1080,8 @@ UtStrtoul64 ( /* Check to see if value is out of range: */ - if (ReturnValue > ((ACPI_INTEGER_MAX - (ACPI_INTEGER) Index) / - (ACPI_INTEGER) Base)) + if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / + (UINT64) Base)) { goto ErrorExit; } diff --git a/sys/contrib/dev/acpica-unix/debugger/dbhistry.c b/sys/contrib/dev/acpica-unix/compiler/asluuid.c similarity index 63% copy from sys/contrib/dev/acpica-unix/debugger/dbhistry.c copy to sys/contrib/dev/acpica-unix/compiler/asluuid.c index e8e8a76bf1..ca6f089954 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica-unix/compiler/asluuid.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dbhistry - debugger HISTORY command + * Module Name: asluuid-- compiler UUID support * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,179 +114,175 @@ *****************************************************************************/ -#include "acpi.h" -#include "accommon.h" -#include "acdebug.h" +#include "aslcompiler.h" -#ifdef ACPI_DEBUGGER +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asluuid") -#define _COMPONENT ACPI_CA_DEBUGGER - ACPI_MODULE_NAME ("dbhistry") - -#define HI_NO_HISTORY 0 -#define HI_RECORD_HISTORY 1 -#define HISTORY_SIZE 20 - - -typedef struct HistoryInfo +/* + * UUID support functions. + * + * This table is used to convert an input UUID ascii string to a 16 byte + * buffer and the reverse. The table maps a UUID buffer index 0-15 to + * the index within the 36-byte UUID string where the associated 2-byte + * hex value can be found. + * + * 36-byte UUID strings are of the form: + * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * Where aa-pp are one byte hex numbers, made up of two hex digits + * + * Note: This table is basically the inverse of the string-to-offset table + * found in the ACPI spec in the description of the ToUUID macro. + */ +static UINT8 Gbl_MapToUuidOffset[16] = { - char Command[80]; - UINT32 CmdNum; + 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 +}; -} HISTORY_INFO; +#define UUID_BUFFER_LENGTH 16 +#define UUID_STRING_LENGTH 36 +/* Positions for required hyphens (dashes) in UUID strings */ -static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; -static UINT16 AcpiGbl_LoHistory = 0; -static UINT16 AcpiGbl_NumHistory = 0; -static UINT16 AcpiGbl_NextHistoryIndex = 0; -static UINT32 AcpiGbl_NextCmdNum = 1; +#define UUID_HYPHEN1_OFFSET 8 +#define UUID_HYPHEN2_OFFSET 13 +#define UUID_HYPHEN3_OFFSET 18 +#define UUID_HYPHEN4_OFFSET 23 /******************************************************************************* * - * FUNCTION: AcpiDbAddToHistory + * FUNCTION: AuValiduateUuid * - * PARAMETERS: CommandLine - Command to add + * PARAMETERS: InString - 36-byte formatted UUID string * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Add a command line to the history buffer. + * DESCRIPTION: Check all 36 characters for correct format * ******************************************************************************/ -void -AcpiDbAddToHistory ( - char *CommandLine) +ACPI_STATUS +AuValidateUuid ( + char *InString) { + UINT32 i; - /* Put command into the next available slot */ - - ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, - CommandLine); - AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum; + if (!InString || (ACPI_STRLEN (InString) != UUID_STRING_LENGTH)) + { + return (AE_BAD_PARAMETER); + } - /* Adjust indexes */ + /* Check all 36 characters for correct format */ - if ((AcpiGbl_NumHistory == HISTORY_SIZE) && - (AcpiGbl_NextHistoryIndex == AcpiGbl_LoHistory)) + for (i = 0; i < UUID_STRING_LENGTH; i++) { - AcpiGbl_LoHistory++; - if (AcpiGbl_LoHistory >= HISTORY_SIZE) + /* Must have 4 hyphens (dashes) in these positions: */ + + if ((i == UUID_HYPHEN1_OFFSET) || + (i == UUID_HYPHEN2_OFFSET) || + (i == UUID_HYPHEN3_OFFSET) || + (i == UUID_HYPHEN4_OFFSET)) { - AcpiGbl_LoHistory = 0; + if (InString[i] != '-') + { + return (AE_BAD_PARAMETER); + } } - } - AcpiGbl_NextHistoryIndex++; - if (AcpiGbl_NextHistoryIndex >= HISTORY_SIZE) - { - AcpiGbl_NextHistoryIndex = 0; - } + /* All other positions must contain hex digits */ - AcpiGbl_NextCmdNum++; - if (AcpiGbl_NumHistory < HISTORY_SIZE) - { - AcpiGbl_NumHistory++; + else + { + if (!isxdigit ((int) InString[i])) + { + return (AE_BAD_PARAMETER); + } + } } + + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiDbDisplayHistory + * FUNCTION: AuConvertStringToUuid * - * PARAMETERS: None + * PARAMETERS: InString - 36-byte formatted UUID string + * UuidBuffer - 16-byte UUID buffer * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Display the contents of the history buffer + * DESCRIPTION: Convert 36-byte formatted UUID string to 16-byte UUID buffer * ******************************************************************************/ -void -AcpiDbDisplayHistory ( - void) +ACPI_STATUS +AuConvertStringToUuid ( + char *InString, + char *UuidBuffer) { UINT32 i; - UINT16 HistoryIndex; - HistoryIndex = AcpiGbl_LoHistory; - - /* Dump entire history buffer */ - - for (i = 0; i < AcpiGbl_NumHistory; i++) + if (!InString || !UuidBuffer) { - AcpiOsPrintf ("%ld %s\n", AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum, - AcpiGbl_HistoryBuffer[HistoryIndex].Command); + return (AE_BAD_PARAMETER); + } - HistoryIndex++; - if (HistoryIndex >= HISTORY_SIZE) - { - HistoryIndex = 0; - } + for (i = 0; i < UUID_BUFFER_LENGTH; i++) + { + UuidBuffer[i] = (char) (UtHexCharToValue (InString[Gbl_MapToUuidOffset[i]]) << 4); + UuidBuffer[i] |= (char) UtHexCharToValue (InString[Gbl_MapToUuidOffset[i] + 1]); } + + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiDbGetFromHistory + * FUNCTION: AuConvertUuidToString * - * PARAMETERS: CommandNumArg - String containing the number of the - * command to be retrieved + * PARAMETERS: UuidBuffer - 16-byte UUID buffer + * OutString - 36-byte formatted UUID string * - * RETURN: Pointer to the retrieved command. Null on error. + * RETURN: Status * - * DESCRIPTION: Get a command from the history buffer + * DESCRIPTION: Convert 16-byte UUID buffer to 36-byte formatted UUID string + * OutString must be 37 bytes to include null terminator. * ******************************************************************************/ -char * -AcpiDbGetFromHistory ( - char *CommandNumArg) +ACPI_STATUS +AuConvertUuidToString ( + char *UuidBuffer, + char *OutString) { UINT32 i; - UINT16 HistoryIndex; - UINT32 CmdNum; - if (CommandNumArg == NULL) + if (!UuidBuffer || !OutString) { - CmdNum = AcpiGbl_NextCmdNum - 1; + return (AE_BAD_PARAMETER); } - else + for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); + OutString[Gbl_MapToUuidOffset[i]] = (UINT8) AslHexLookup[(UuidBuffer[i] >> 4) & 0xF]; + OutString[Gbl_MapToUuidOffset[i] + 1] = (UINT8) AslHexLookup[UuidBuffer[i] & 0xF]; } - /* Search history buffer */ - - HistoryIndex = AcpiGbl_LoHistory; - for (i = 0; i < AcpiGbl_NumHistory; i++) - { - if (AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum == CmdNum) - { - /* Found the commnad, return it */ - - return (AcpiGbl_HistoryBuffer[HistoryIndex].Command); - } + /* Insert required hyphens (dashes) */ + OutString[UUID_HYPHEN1_OFFSET] = + OutString[UUID_HYPHEN2_OFFSET] = + OutString[UUID_HYPHEN3_OFFSET] = + OutString[UUID_HYPHEN4_OFFSET] = '-'; - HistoryIndex++; - if (HistoryIndex >= HISTORY_SIZE) - { - HistoryIndex = 0; - } - } - - AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); - return (NULL); + OutString[UUID_STRING_LENGTH] = 0; /* Null terminate */ + return (AE_OK); } - -#endif /* ACPI_DEBUGGER */ - diff --git a/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c b/sys/contrib/dev/acpica-unix/compiler/aslwalks.c similarity index 52% copy from sys/contrib/dev/acpica-unix/compiler/aslanalyze.c copy to sys/contrib/dev/acpica-unix/compiler/aslwalks.c index d44adda8ff..81db6f2b2e 100644 --- a/sys/contrib/dev/acpica-unix/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica-unix/compiler/aslwalks.c @@ -1,7 +1,6 @@ - /****************************************************************************** * - * Module Name: aslanalyze.c - check for semantic errors + * Module Name: aslwalks.c - major analytical parse tree walks * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,763 +119,1229 @@ #include "acparser.h" #include "amlcode.h" -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslanalyze") - -/* Local prototypes */ - -static UINT32 -AnMapArgTypeToBtype ( - UINT32 ArgType); - -static UINT32 -AnMapEtypeToBtype ( - UINT32 Etype); - -static void -AnFormatBtype ( - char *Buffer, - UINT32 Btype); - -static UINT32 -AnGetBtype ( - ACPI_PARSE_OBJECT *Op); - -static UINT32 -AnCheckForReservedName ( - ACPI_PARSE_OBJECT *Op, - char *Name); - -static void -AnCheckForReservedMethod ( - ACPI_PARSE_OBJECT *Op, - ASL_METHOD_INFO *MethodInfo); - -static UINT32 -AnMapObjTypeToBtype ( - ACPI_PARSE_OBJECT *Op); - -static BOOLEAN -AnLastStatementIsReturn ( - ACPI_PARSE_OBJECT *Op); - -static void -AnCheckMethodReturnValue ( - ACPI_PARSE_OBJECT *Op, - const ACPI_OPCODE_INFO *OpInfo, - ACPI_PARSE_OBJECT *ArgOp, - UINT32 RequiredBtypes, - UINT32 ThisNodeBtype); - -static BOOLEAN -AnIsInternalMethod ( - ACPI_PARSE_OBJECT *Op); -static UINT32 -AnGetInternalMethodReturnType ( - ACPI_PARSE_OBJECT *Op); - -BOOLEAN -AnIsResultUsed ( - ACPI_PARSE_OBJECT *Op); +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslwalks") /******************************************************************************* * - * FUNCTION: AnIsInternalMethod + * FUNCTION: AnMethodAnalysisWalkBegin * - * PARAMETERS: Op - Current op + * PARAMETERS: ASL_WALK_CALLBACK * - * RETURN: Boolean + * RETURN: Status * - * DESCRIPTION: Check for an internal control method. + * DESCRIPTION: Descending callback for the analysis walk. Check methods for: + * 1) Initialized local variables + * 2) Valid arguments + * 3) Return types * ******************************************************************************/ -static BOOLEAN -AnIsInternalMethod ( - ACPI_PARSE_OBJECT *Op) +ACPI_STATUS +AnMethodAnalysisWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) { + ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; + ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; + ACPI_PARSE_OBJECT *Next; + UINT32 RegisterNumber; + UINT32 i; + char LocalName[] = "Local0"; + char ArgName[] = "Arg0"; + ACPI_PARSE_OBJECT *ArgNode; + ACPI_PARSE_OBJECT *NextType; + ACPI_PARSE_OBJECT *NextParamType; + UINT8 ActualArgs = 0; - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) - { - return (TRUE); - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: AnGetInternalMethodReturnType - * - * PARAMETERS: Op - Current op - * - * RETURN: Btype - * - * DESCRIPTION: Get the return type of an internal method - * - ******************************************************************************/ - -static UINT32 -AnGetInternalMethodReturnType ( - ACPI_PARSE_OBJECT *Op) -{ - if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) || - (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI"))) + switch (Op->Asl.ParseOpcode) { - return (ACPI_BTYPE_STRING); - } + case PARSEOP_METHOD: - return (0); -} + TotalMethods++; + /* Create and init method info */ -/******************************************************************************* - * - * FUNCTION: AnMapArgTypeToBtype - * - * PARAMETERS: ArgType - The ARGI required type(s) for this argument, - * from the opcode info table - * - * RETURN: The corresponding Bit-encoded types - * - * DESCRIPTION: Convert an encoded ARGI required argument type code into a - * bitfield type code. Implements the implicit source conversion - * rules. - * - ******************************************************************************/ + MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); + MethodInfo->Next = WalkInfo->MethodStack; + MethodInfo->Op = Op; -static UINT32 -AnMapArgTypeToBtype ( - UINT32 ArgType) -{ + WalkInfo->MethodStack = MethodInfo; - switch (ArgType) - { + /* Get the name node, ignored here */ - /* Simple types */ + Next = Op->Asl.Child; + + /* Get the NumArguments node */ - case ARGI_ANYTYPE: - return (ACPI_BTYPE_OBJECTS_AND_REFS); + Next = Next->Asl.Next; + MethodInfo->NumArguments = (UINT8) + (((UINT8) Next->Asl.Value.Integer) & 0x07); - case ARGI_PACKAGE: - return (ACPI_BTYPE_PACKAGE); + /* Get the SerializeRule and SyncLevel nodes, ignored here */ - case ARGI_EVENT: - return (ACPI_BTYPE_EVENT); + Next = Next->Asl.Next; + Next = Next->Asl.Next; + ArgNode = Next; - case ARGI_MUTEX: - return (ACPI_BTYPE_MUTEX); + /* Get the ReturnType node */ - case ARGI_DDBHANDLE: - /* - * DDBHandleObject := SuperName - * ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload - */ - return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE); + Next = Next->Asl.Next; - /* Interchangeable types */ - /* - * Source conversion rules: - * Integer, String, and Buffer are all interchangeable - */ - case ARGI_INTEGER: - case ARGI_STRING: - case ARGI_BUFFER: - case ARGI_BUFFER_OR_STRING: - case ARGI_COMPUTEDATA: - return (ACPI_BTYPE_COMPUTE_DATA); + NextType = Next->Asl.Child; + while (NextType) + { + /* Get and map each of the ReturnTypes */ - /* References */ + MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + NextType = NextType->Asl.Next; + } - case ARGI_INTEGER_REF: - return (ACPI_BTYPE_INTEGER); + /* Get the ParameterType node */ - case ARGI_OBJECT_REF: - return (ACPI_BTYPE_ALL_OBJECTS); + Next = Next->Asl.Next; - case ARGI_DEVICE_REF: - return (ACPI_BTYPE_DEVICE_OBJECTS); + NextType = Next->Asl.Child; + while (NextType) + { + if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + NextParamType = NextType->Asl.Child; + while (NextParamType) + { + MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); + NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + NextParamType = NextParamType->Asl.Next; + } + } + else + { + MethodInfo->ValidArgTypes[ActualArgs] = + AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + ActualArgs++; + } - case ARGI_REFERENCE: - return (ACPI_BTYPE_REFERENCE); + NextType = NextType->Asl.Next; + } - case ARGI_TARGETREF: - case ARGI_FIXED_TARGET: - case ARGI_SIMPLE_TARGET: - return (ACPI_BTYPE_OBJECTS_AND_REFS); + if ((MethodInfo->NumArguments) && + (MethodInfo->NumArguments != ActualArgs)) + { + /* error: Param list did not match number of args */ + } - /* Complex types */ + /* Allow numarguments == 0 for Function() */ - case ARGI_DATAOBJECT: + if ((!MethodInfo->NumArguments) && (ActualArgs)) + { + MethodInfo->NumArguments = ActualArgs; + ArgNode->Asl.Value.Integer |= ActualArgs; + } /* - * Buffer, string, package or reference to a Op - - * Used only by SizeOf operator + * Actual arguments are initialized at method entry. + * All other ArgX "registers" can be used as locals, so we + * track their initialization. */ - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + for (i = 0; i < MethodInfo->NumArguments; i++) + { + MethodInfo->ArgInitialized[i] = TRUE; + } + break; - case ARGI_COMPLEXOBJ: - /* Buffer, String, or package */ + case PARSEOP_METHODCALL: - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); + if (MethodInfo && + (Op->Asl.Node == MethodInfo->Op->Asl.Node)) + { + AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName); + } + break; - case ARGI_REF_OR_STRING: - return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); - case ARGI_REGION_OR_BUFFER: + case PARSEOP_LOCAL0: + case PARSEOP_LOCAL1: + case PARSEOP_LOCAL2: + case PARSEOP_LOCAL3: + case PARSEOP_LOCAL4: + case PARSEOP_LOCAL5: + case PARSEOP_LOCAL6: + case PARSEOP_LOCAL7: - /* Used by Load() only. Allow buffers in addition to regions/fields */ + if (!MethodInfo) + { + /* + * Local was used outside a control method, or there was an error + * in the method declaration. + */ + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + return (AE_ERROR); + } - return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); + RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); - case ARGI_DATAREFOBJ: - return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | - ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + /* + * If the local is being used as a target, mark the local + * initialized + */ + if (Op->Asl.CompileFlags & NODE_IS_TARGET) + { + MethodInfo->LocalInitialized[RegisterNumber] = TRUE; + } - default: + /* + * Otherwise, this is a reference, check if the local + * has been previously initialized. + * + * The only operator that accepts an uninitialized value is ObjectType() + */ + else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) + { + LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); + AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); + } break; - } - - return (ACPI_BTYPE_OBJECTS_AND_REFS); -} -/******************************************************************************* - * - * FUNCTION: AnMapEtypeToBtype - * - * PARAMETERS: Etype - Encoded ACPI Type - * - * RETURN: Btype corresponding to the Etype - * - * DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the - * operand conversion rules. In other words, returns the type(s) - * this Etype is implicitly converted to during interpretation. - * - ******************************************************************************/ - -static UINT32 -AnMapEtypeToBtype ( - UINT32 Etype) -{ - + case PARSEOP_ARG0: + case PARSEOP_ARG1: + case PARSEOP_ARG2: + case PARSEOP_ARG3: + case PARSEOP_ARG4: + case PARSEOP_ARG5: + case PARSEOP_ARG6: - if (Etype == ACPI_TYPE_ANY) - { - return ACPI_BTYPE_OBJECTS_AND_REFS; - } + if (!MethodInfo) + { + /* + * Arg was used outside a control method, or there was an error + * in the method declaration. + */ + AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); + return (AE_ERROR); + } - /* Try the standard ACPI data types */ + RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8; + ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30); - if (Etype <= ACPI_TYPE_EXTERNAL_MAX) - { /* - * This switch statement implements the allowed operand conversion - * rules as per the "ASL Data Types" section of the ACPI - * specification. + * If the Arg is being used as a target, mark the local + * initialized */ - switch (Etype) + if (Op->Asl.CompileFlags & NODE_IS_TARGET) { - case ACPI_TYPE_INTEGER: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE); + MethodInfo->ArgInitialized[RegisterNumber] = TRUE; + } - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - return (ACPI_BTYPE_COMPUTE_DATA); + /* + * Otherwise, this is a reference, check if the Arg + * has been previously initialized. + * + * The only operator that accepts an uninitialized value is ObjectType() + */ + else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) + { + AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); + } - case ACPI_TYPE_PACKAGE: - return (ACPI_BTYPE_PACKAGE); + /* Flag this arg if it is not a "real" argument to the method */ - case ACPI_TYPE_FIELD_UNIT: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); + if (RegisterNumber >= MethodInfo->NumArguments) + { + AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName); + } + break; - case ACPI_TYPE_BUFFER_FIELD: - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD); - case ACPI_TYPE_DDB_HANDLE: - return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); + case PARSEOP_RETURN: - case ACPI_BTYPE_DEBUG_OBJECT: + if (!MethodInfo) + { + /* + * Probably was an error in the method declaration, + * no additional error here + */ + ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); + return (AE_ERROR); + } - /* Cannot be used as a source operand */ + /* Child indicates a return value */ - return (0); - - default: - return (1 << (Etype - 1)); + if ((Op->Asl.Child) && + (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) + { + MethodInfo->NumReturnWithValue++; } - } - - /* Try the internal data types */ - - switch (Etype) - { - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - /* Named fields can be either Integer/Buffer/String */ - - return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); - - case ACPI_TYPE_LOCAL_ALIAS: - - return (ACPI_BTYPE_INTEGER); - - - case ACPI_TYPE_LOCAL_RESOURCE: - case ACPI_TYPE_LOCAL_RESOURCE_FIELD: - - return (ACPI_BTYPE_REFERENCE); + else + { + MethodInfo->NumReturnNoValue++; + } + break; - default: - printf ("Unhandled encoded type: %X\n", Etype); - return (0); - } -} + case PARSEOP_BREAK: + case PARSEOP_CONTINUE: -/******************************************************************************* - * - * FUNCTION: AnFormatBtype - * - * PARAMETERS: Btype - Bitfield of ACPI types - * Buffer - Where to put the ascii string - * - * RETURN: None. - * - * DESCRIPTION: Convert a Btype to a string of ACPI types - * - ******************************************************************************/ + Next = Op->Asl.Parent; + while (Next) + { + if (Next->Asl.ParseOpcode == PARSEOP_WHILE) + { + break; + } + Next = Next->Asl.Parent; + } -static void -AnFormatBtype ( - char *Buffer, - UINT32 Btype) -{ - UINT32 Type; - BOOLEAN First = TRUE; + if (!Next) + { + AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL); + } + break; - *Buffer = 0; + case PARSEOP_STALL: - if (Btype == 0) - { - strcat (Buffer, "NoReturnValue"); - return; - } + /* We can range check if the argument is an integer */ - for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++) - { - if (Btype & 0x00000001) + if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && + (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) { - if (!First) - { - strcat (Buffer, "|"); - } - First = FALSE; - strcat (Buffer, AcpiUtGetTypeName (Type)); + AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); } - Btype >>= 1; - } + break; - if (Btype & 0x00000001) - { - if (!First) - { - strcat (Buffer, "|"); - } - First = FALSE; - strcat (Buffer, "Reference"); - } - Btype >>= 1; - if (Btype & 0x00000001) - { - if (!First) + case PARSEOP_DEVICE: + case PARSEOP_EVENT: + case PARSEOP_MUTEX: + case PARSEOP_OPERATIONREGION: + case PARSEOP_POWERRESOURCE: + case PARSEOP_PROCESSOR: + case PARSEOP_THERMALZONE: + + /* + * The first operand is a name to be created in the namespace. + * Check against the reserved list. + */ + i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); + if (i < ACPI_VALID_RESERVED_NAME_MAX) { - strcat (Buffer, "|"); + AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); } - First = FALSE; - strcat (Buffer, "Resource"); - } -} + break; -/******************************************************************************* - * - * FUNCTION: AnGetBtype - * - * PARAMETERS: Op - Parse node whose type will be returned. - * - * RETURN: The Btype associated with the Op. - * - * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node. - * Handles the case where the node is a name or method call and - * the actual type must be obtained from the namespace node. - * - ******************************************************************************/ + case PARSEOP_NAME: -static UINT32 -AnGetBtype ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_PARSE_OBJECT *ReferencedNode; - UINT32 ThisNodeBtype = 0; + /* Typecheck any predefined names statically defined with Name() */ + ApCheckForPredefinedObject (Op, Op->Asl.NameSeg); - if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || - (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || - (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) - { - Node = Op->Asl.Node; - if (!Node) - { - DbgPrint (ASL_DEBUG_OUTPUT, - "No attached Nsnode: [%s] at line %d name [%s], ignoring typecheck\n", - Op->Asl.ParseOpName, Op->Asl.LineNumber, - Op->Asl.ExternalName); - return ACPI_UINT32_MAX; - } + /* Special typechecking for _HID */ - ThisNodeBtype = AnMapEtypeToBtype (Node->Type); - if (!ThisNodeBtype) + if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, - "could not map type"); + Next = Op->Asl.Child->Asl.Next; + AnCheckId (Next, ASL_TYPE_HID); } - /* - * Since it was a named reference, enable the - * reference bit also - */ - ThisNodeBtype |= ACPI_BTYPE_REFERENCE; + /* Special typechecking for _CID */ - if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) + else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) { - ReferencedNode = Node->Op; - if (!ReferencedNode) - { - /* Check for an internal method */ + Next = Op->Asl.Child->Asl.Next; - if (AnIsInternalMethod (Op)) + if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) || + (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) + { + Next = Next->Asl.Child; + while (Next) { - return (AnGetInternalMethodReturnType (Op)); + AnCheckId (Next, ASL_TYPE_CID); + Next = Next->Asl.Next; } - - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, - "null Op pointer"); - return ACPI_UINT32_MAX; - } - - if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED) - { - ThisNodeBtype = ReferencedNode->Asl.AcpiBtype; } else { - return (ACPI_UINT32_MAX -1); + AnCheckId (Next, ASL_TYPE_CID); } } - } - else - { - ThisNodeBtype = Op->Asl.AcpiBtype; + break; + + + default: + break; } - return (ThisNodeBtype); + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AnCheckForReservedName + * FUNCTION: AnMethodAnalysisWalkEnd * - * PARAMETERS: Op - A parse node - * Name - NameSeg to check + * PARAMETERS: ASL_WALK_CALLBACK * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Check a NameSeg against the reserved list. + * DESCRIPTION: Ascending callback for analysis walk. Complete method + * return analysis. * ******************************************************************************/ -static UINT32 -AnCheckForReservedName ( +ACPI_STATUS +AnMethodAnalysisWalkEnd ( ACPI_PARSE_OBJECT *Op, - char *Name) + UINT32 Level, + void *Context) { - UINT32 i; + ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; + ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; - if (Name[0] == 0) + switch (Op->Asl.ParseOpcode) { - AcpiOsPrintf ("Found a null name, external = %s\n", - Op->Asl.ExternalName); - } + case PARSEOP_METHOD: + case PARSEOP_RETURN: + if (!MethodInfo) + { + printf ("No method info for method! [%s]\n", Op->Asl.Namepath); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "No method info for this method"); - /* All reserved names are prefixed with a single underscore */ + CmCleanupAndExit (); + return (AE_AML_INTERNAL); + } + break; - if (Name[0] != '_') - { - return (ACPI_NOT_RESERVED_NAME); + default: + break; } - /* Check for a standard reserved method name */ - - for (i = 0; ReservedMethods[i].Name; i++) + switch (Op->Asl.ParseOpcode) { - if (ACPI_COMPARE_NAME (Name, ReservedMethods[i].Name)) - { - if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) - { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, - Op->Asl.ExternalName); - return (ACPI_PREDEFINED_NAME); - } - else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) - { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, - Op->Asl.ExternalName); - return (ACPI_PREDEFINED_NAME); - } + case PARSEOP_METHOD: - /* Return index into reserved array */ + WalkInfo->MethodStack = MethodInfo->Next; - return i; + /* + * Check if there is no return statement at the end of the + * method AND we can actually get there -- i.e., the execution + * of the method can possibly terminate without a return statement. + */ + if ((!AnLastStatementIsReturn (Op)) && + (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT))) + { + /* + * No return statement, and execution can possibly exit + * via this path. This is equivalent to Return () + */ + MethodInfo->NumReturnNoValue++; } - } - - /* - * Now check for the "special" reserved names -- - * GPE: _Lxx - * GPE: _Exx - * EC: _Qxx - */ - if ((Name[1] == 'L') || - (Name[1] == 'E') || - (Name[1] == 'Q')) - { - /* The next two characters must be hex digits */ - if ((isxdigit (Name[2])) && - (isxdigit (Name[3]))) + /* + * Check for case where some return statements have a return value + * and some do not. Exit without a return statement is a return with + * no value + */ + if (MethodInfo->NumReturnNoValue && + MethodInfo->NumReturnWithValue) { - return (ACPI_EVENT_RESERVED_NAME); + AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, + Op->Asl.ExternalName); } - } - - - /* Check for the names reserved for the compiler itself: _T_x */ - - else if ((Op->Asl.ExternalName[1] == 'T') && - (Op->Asl.ExternalName[2] == '_')) - { - /* Ignore if actually emitted by the compiler */ - if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED) + /* + * If there are any RETURN() statements with no value, or there is a + * control path that allows the method to exit without a return value, + * we mark the method as a method that does not return a value. This + * knowledge can be used to check method invocations that expect a + * returned value. + */ + if (MethodInfo->NumReturnNoValue) { - return (ACPI_NOT_RESERVED_NAME); + if (MethodInfo->NumReturnWithValue) + { + Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL; + } + else + { + Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL; + } } /* - * Was not actually emitted by the compiler. This is a special case, - * however. If the ASL code being compiled was the result of a - * dissasembly, it may possibly contain valid compiler-emitted names - * of the form "_T_x". We don't want to issue an error or even a - * warning and force the user to manually change the names. So, we - * will issue a remark instead. + * Check predefined method names for correct return behavior + * and correct number of arguments */ - AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); - return (ACPI_COMPILER_RESERVED_NAME); - } - - /* - * The name didn't match any of the known reserved names. Flag it as a - * warning, since the entire namespace starting with an underscore is - * reserved by the ACPI spec. - */ - AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, - Op->Asl.ExternalName); - - return (ACPI_NOT_RESERVED_NAME); -} - - -/******************************************************************************* - * - * FUNCTION: AnCheckForReservedMethod - * - * PARAMETERS: Op - A parse node of type "METHOD". - * MethodInfo - Saved info about this method - * - * RETURN: None - * - * DESCRIPTION: If method is a reserved name, check that the number of arguments - * and the return type (returns a value or not) is correct. - * - ******************************************************************************/ - -static void -AnCheckForReservedMethod ( - ACPI_PARSE_OBJECT *Op, - ASL_METHOD_INFO *MethodInfo) -{ - UINT32 Index; - UINT32 RequiredArgsCurrent; - UINT32 RequiredArgsOld; - - - /* Check for a match against the reserved name list */ - - Index = AnCheckForReservedName (Op, Op->Asl.NameSeg); + ApCheckForPredefinedMethod (Op, MethodInfo); - switch (Index) - { - case ACPI_NOT_RESERVED_NAME: - case ACPI_PREDEFINED_NAME: - case ACPI_COMPILER_RESERVED_NAME: + /* Special check for two names like _L01 and _E01 in same scope */ - /* Just return, nothing to do */ + ApCheckForGpeNameConflict (Op); + ACPI_FREE (MethodInfo); break; - case ACPI_EVENT_RESERVED_NAME: - - Gbl_ReservedMethods++; - - /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */ + case PARSEOP_NAME: - if (MethodInfo->NumArguments != 0) - { - sprintf (MsgBuffer, "%s requires %d", - Op->Asl.ExternalName, 0); + /* Special check for two names like _L01 and _E01 in same scope */ - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); - } + ApCheckForGpeNameConflict (Op); break; - default: + case PARSEOP_RETURN: - Gbl_ReservedMethods++; + /* + * If the parent is a predefined method name, attempt to typecheck + * the return value. Only static types can be validated. + */ + ApCheckPredefinedReturnValue (Op, MethodInfo); /* - * Matched a reserved method name - * - * Validate the ASL-defined argument count. Allow two different legal - * arg counts. + * The parent block does not "exit" and continue execution -- the + * method is terminated here with the Return() statement. */ - RequiredArgsCurrent = ReservedMethods[Index].NumArguments & 0x0F; - RequiredArgsOld = ReservedMethods[Index].NumArguments >> 4; + Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - if ((MethodInfo->NumArguments != RequiredArgsCurrent) && - (MethodInfo->NumArguments != RequiredArgsOld)) - { - sprintf (MsgBuffer, "%s requires %d", - ReservedMethods[Index].Name, - RequiredArgsCurrent); + /* Used in the "typing" pass later */ - if (MethodInfo->NumArguments > RequiredArgsCurrent) - { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, - MsgBuffer); - } - else - { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, - MsgBuffer); - } - } + Op->Asl.ParentMethod = MethodInfo->Op; - if (MethodInfo->NumReturnNoValue && - ReservedMethods[Index].Flags & ASL_RSVD_RETURN_VALUE) + /* + * If there is a peer node after the return statement, then this + * node is unreachable code -- i.e., it won't be executed because of + * the preceeding Return() statement. + */ + if (Op->Asl.Next) { - sprintf (MsgBuffer, "%s", ReservedMethods[Index].Name); - - AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer); + AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); } break; - } -} -/******************************************************************************* + case PARSEOP_IF: + + if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && + (Op->Asl.Next) && + (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE)) + { + /* + * This IF has a corresponding ELSE. The IF block has no exit, + * (it contains an unconditional Return) + * mark the ELSE block to remember this fact. + */ + Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT; + } + break; + + + case PARSEOP_ELSE: + + if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && + (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT)) + { + /* + * This ELSE block has no exit and the corresponding IF block + * has no exit either. Therefore, the parent node has no exit. + */ + Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; + } + break; + + + default: + + if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && + (Op->Asl.Parent)) + { + /* If this node has no exit, then the parent has no exit either */ + + Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; + } + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AnMethodTypingWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback for typing walk. Complete the method + * return analysis. Check methods for: + * 1) Initialized local variables + * 2) Valid arguments + * 3) Return types + * + ******************************************************************************/ + +ACPI_STATUS +AnMethodTypingWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + UINT32 ThisNodeBtype; + + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_METHOD: + + Op->Asl.CompileFlags |= NODE_METHOD_TYPED; + break; + + case PARSEOP_RETURN: + + if ((Op->Asl.Child) && + (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) + { + ThisNodeBtype = AnGetBtype (Op->Asl.Child); + + if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) && + (ThisNodeBtype == (ACPI_UINT32_MAX -1))) + { + /* + * The called method is untyped at this time (typically a + * forward reference). + * + * Check for a recursive method call first. + */ + if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op) + { + /* We must type the method here */ + + TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, + ASL_WALK_VISIT_UPWARD, NULL, + AnMethodTypingWalkEnd, NULL); + + ThisNodeBtype = AnGetBtype (Op->Asl.Child); + } + } + + /* Returns a value, save the value type */ + + if (Op->Asl.ParentMethod) + { + Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisNodeBtype; + } + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AnOperandTypecheckWalkEnd + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback for analysis walk. Complete method + * return analysis. + * + ******************************************************************************/ + +ACPI_STATUS +AnOperandTypecheckWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + const ACPI_OPCODE_INFO *OpInfo; + UINT32 RuntimeArgTypes; + UINT32 RuntimeArgTypes2; + UINT32 RequiredBtypes; + UINT32 ThisNodeBtype; + UINT32 CommonBtypes; + UINT32 OpcodeClass; + ACPI_PARSE_OBJECT *ArgOp; + UINT32 ArgType; + + + switch (Op->Asl.AmlOpcode) + { + case AML_RAW_DATA_BYTE: + case AML_RAW_DATA_WORD: + case AML_RAW_DATA_DWORD: + case AML_RAW_DATA_QWORD: + case AML_RAW_DATA_BUFFER: + case AML_RAW_DATA_CHAIN: + case AML_PACKAGE_LENGTH: + case AML_UNASSIGNED_OPCODE: + case AML_DEFAULT_ARG_OP: + + /* Ignore the internal (compiler-only) AML opcodes */ + + return (AE_OK); + + default: + break; + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + if (!OpInfo) + { + return (AE_OK); + } + + ArgOp = Op->Asl.Child; + RuntimeArgTypes = OpInfo->RuntimeArgs; + OpcodeClass = OpInfo->Class; + +#ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE + /* + * Update 11/2008: In practice, we can't perform this check. A simple + * analysis is not sufficient. Also, it can cause errors when compiling + * disassembled code because of the way Switch operators are implemented + * (a While(One) loop with a named temp variable created within.) + */ + + /* + * If we are creating a named object, check if we are within a while loop + * by checking if the parent is a WHILE op. This is a simple analysis, but + * probably sufficient for many cases. + * + * Allow Scope(), Buffer(), and Package(). + */ + if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) || + ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE))) + { + if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP) + { + AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL); + } + } +#endif + + /* + * Special case for control opcodes IF/RETURN/WHILE since they + * have no runtime arg list (at this time) + */ + switch (Op->Asl.AmlOpcode) + { + case AML_IF_OP: + case AML_WHILE_OP: + case AML_RETURN_OP: + + if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) + { + /* Check for an internal method */ + + if (AnIsInternalMethod (ArgOp)) + { + return (AE_OK); + } + + /* The lone arg is a method call, check it */ + + RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER); + if (Op->Asl.AmlOpcode == AML_RETURN_OP) + { + RequiredBtypes = 0xFFFFFFFF; + } + + ThisNodeBtype = AnGetBtype (ArgOp); + if (ThisNodeBtype == ACPI_UINT32_MAX) + { + return (AE_OK); + } + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, + RequiredBtypes, ThisNodeBtype); + } + return (AE_OK); + + default: + break; + } + + /* Ignore the non-executable opcodes */ + + if (RuntimeArgTypes == ARGI_INVALID_OPCODE) + { + return (AE_OK); + } + + switch (OpcodeClass) + { + case AML_CLASS_EXECUTE: + case AML_CLASS_CREATE: + case AML_CLASS_CONTROL: + case AML_CLASS_RETURN_VALUE: + + /* TBD: Change class or fix typechecking for these */ + + if ((Op->Asl.AmlOpcode == AML_BUFFER_OP) || + (Op->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + break; + } + + /* Reverse the runtime argument list */ + + RuntimeArgTypes2 = 0; + while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes))) + { + RuntimeArgTypes2 <<= ARG_TYPE_WIDTH; + RuntimeArgTypes2 |= ArgType; + INCREMENT_ARG_LIST (RuntimeArgTypes); + } + + while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2))) + { + RequiredBtypes = AnMapArgTypeToBtype (ArgType); + + ThisNodeBtype = AnGetBtype (ArgOp); + if (ThisNodeBtype == ACPI_UINT32_MAX) + { + goto NextArgument; + } + + /* Examine the arg based on the required type of the arg */ + + switch (ArgType) + { + case ARGI_TARGETREF: + + if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) + { + /* ZERO is the placeholder for "don't store result" */ + + ThisNodeBtype = RequiredBtypes; + break; + } + + if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) + { + /* + * This is the case where an original reference to a resource + * descriptor field has been replaced by an (Integer) offset. + * These named fields are supported at compile-time only; + * the names are not passed to the interpreter (via the AML). + */ + if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || + (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, ArgOp, NULL); + } + else + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, NULL); + } + break; + } + + if ((ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) || + (ArgOp->Asl.ParseOpcode == PARSEOP_DEREFOF)) + { + break; + } + + ThisNodeBtype = RequiredBtypes; + break; + + + case ARGI_REFERENCE: /* References */ + case ARGI_INTEGER_REF: + case ARGI_OBJECT_REF: + case ARGI_DEVICE_REF: + + switch (ArgOp->Asl.ParseOpcode) + { + case PARSEOP_LOCAL0: + case PARSEOP_LOCAL1: + case PARSEOP_LOCAL2: + case PARSEOP_LOCAL3: + case PARSEOP_LOCAL4: + case PARSEOP_LOCAL5: + case PARSEOP_LOCAL6: + case PARSEOP_LOCAL7: + + /* TBD: implement analysis of current value (type) of the local */ + /* For now, just treat any local as a typematch */ + + /*ThisNodeBtype = RequiredBtypes;*/ + break; + + case PARSEOP_ARG0: + case PARSEOP_ARG1: + case PARSEOP_ARG2: + case PARSEOP_ARG3: + case PARSEOP_ARG4: + case PARSEOP_ARG5: + case PARSEOP_ARG6: + + /* Hard to analyze argument types, sow we won't */ + /* For now, just treat any arg as a typematch */ + + /* ThisNodeBtype = RequiredBtypes; */ + break; + + case PARSEOP_DEBUG: + break; + + case PARSEOP_REFOF: + case PARSEOP_INDEX: + default: + break; + + } + break; + + case ARGI_INTEGER: + default: + break; + } + + + CommonBtypes = ThisNodeBtype & RequiredBtypes; + + if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) + { + if (AnIsInternalMethod (ArgOp)) + { + return (AE_OK); + } + + /* Check a method call for a valid return value */ + + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, + RequiredBtypes, ThisNodeBtype); + } + + /* + * Now check if the actual type(s) match at least one + * bit to the required type + */ + else if (!CommonBtypes) + { + /* No match -- this is a type mismatch error */ + + AnFormatBtype (StringBuffer, ThisNodeBtype); + AnFormatBtype (StringBuffer2, RequiredBtypes); + + sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]", + StringBuffer, OpInfo->Name, StringBuffer2); + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); + } + + NextArgument: + ArgOp = ArgOp->Asl.Next; + INCREMENT_ARG_LIST (RuntimeArgTypes2); + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AnOtherSemanticAnalysisWalkBegin + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Descending callback for the analysis walk. Checks for + * miscellaneous issues in the code. + * + ******************************************************************************/ + +ACPI_STATUS +AnOtherSemanticAnalysisWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_PARSE_OBJECT *ArgNode; + ACPI_PARSE_OBJECT *PrevArgNode = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + + /* + * Determine if an execution class operator actually does something by + * checking if it has a target and/or the function return value is used. + * (Target is optional, so a standalone statement can actually do nothing.) + */ + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (OpInfo->Flags & AML_HAS_RETVAL) && + (!AnIsResultUsed (Op))) + { + if (OpInfo->Flags & AML_HAS_TARGET) + { + /* + * Find the target node, it is always the last child. If the traget + * is not specified in the ASL, a default node of type Zero was + * created by the parser. + */ + ArgNode = Op->Asl.Child; + while (ArgNode->Asl.Next) + { + PrevArgNode = ArgNode; + ArgNode = ArgNode->Asl.Next; + } + + /* Divide() is the only weird case, it has two targets */ + + if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) + { + if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && + (PrevArgNode) && + (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) + { + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); + } + } + else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) + { + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); + } + } + else + { + /* + * Has no target and the result is not used. Only a couple opcodes + * can have this combination. + */ + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_ACQUIRE: + case PARSEOP_WAIT: + case PARSEOP_LOADTABLE: + break; + + default: + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); + break; + } + } + } + + + /* + * Semantic checks for individual ASL operators + */ + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_ACQUIRE: + case PARSEOP_WAIT: + /* + * Emit a warning if the timeout parameter for these operators is not + * ACPI_WAIT_FOREVER, and the result value from the operator is not + * checked, meaning that a timeout could happen, but the code + * would not know about it. + */ + + /* First child is the namepath, 2nd child is timeout */ + + ArgNode = Op->Asl.Child; + ArgNode = ArgNode->Asl.Next; + + /* + * Check for the WAIT_FOREVER case - defined by the ACPI spec to be + * 0xFFFF or greater + */ + if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || + (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && + (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) + { + break; + } + + /* + * The operation could timeout. If the return value is not used + * (indicates timeout occurred), issue a warning + */ + if (!AnIsResultUsed (Op)) + { + AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, + Op->Asl.ExternalName); + } + break; + + case PARSEOP_CREATEFIELD: + /* + * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand + */ + ArgNode = Op->Asl.Child; + ArgNode = ArgNode->Asl.Next; + ArgNode = ArgNode->Asl.Next; + + if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) || + ((ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER) && + (ArgNode->Asl.Value.Integer == 0))) + { + AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgNode, NULL); + } + break; + + default: + break; + } + + return (AE_OK); +} +/****************************************************************************** + * + * Module Name: aslwalks.c - major analytical parse tree walks + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. * - * FUNCTION: AnMapObjTypeToBtype + * 4. Disclaimer and Export Compliance * - * PARAMETERS: Op - A parse node + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. * - * RETURN: A Btype + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. * - * DESCRIPTION: Map object to the associated "Btype" + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. * - ******************************************************************************/ - -static UINT32 -AnMapObjTypeToBtype ( - ACPI_PARSE_OBJECT *Op) -{ - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */ - return (ACPI_BTYPE_BUFFER_FIELD); - - case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */ - return (ACPI_BTYPE_BUFFER); - - case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */ - return (ACPI_BTYPE_DDB_HANDLE); - - case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */ - return (ACPI_BTYPE_DEVICE); - - case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */ - return (ACPI_BTYPE_EVENT); - - case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */ - return (ACPI_BTYPE_FIELD_UNIT); - - case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */ - return (ACPI_BTYPE_INTEGER); - - case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */ - return (ACPI_BTYPE_METHOD); - - case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */ - return (ACPI_BTYPE_MUTEX); - - case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */ - return (ACPI_BTYPE_REGION); - - case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */ - return (ACPI_BTYPE_PACKAGE); - - case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */ - return (ACPI_BTYPE_POWER); + *****************************************************************************/ - case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */ - return (ACPI_BTYPE_STRING); - case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */ - return (ACPI_BTYPE_THERMAL); +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "acparser.h" +#include "amlcode.h" - case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */ - return (ACPI_BTYPE_OBJECTS_AND_REFS); - default: - return (0); - } -} +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslwalks") /******************************************************************************* @@ -1187,7 +1652,7 @@ AnMethodAnalysisWalkBegin ( * The first operand is a name to be created in the namespace. * Check against the reserved list. */ - i = AnCheckForReservedName (Op, Op->Asl.NameSeg); + i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); if (i < ACPI_VALID_RESERVED_NAME_MAX) { AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); @@ -1197,54 +1662,38 @@ AnMethodAnalysisWalkBegin ( case PARSEOP_NAME: - i = AnCheckForReservedName (Op, Op->Asl.NameSeg); - if (i < ACPI_VALID_RESERVED_NAME_MAX) - { - if (ReservedMethods[i].NumArguments > 0) - { - /* - * This reserved name must be a control method because - * it must have arguments - */ - AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, - "with arguments"); - } + /* Typecheck any predefined names statically defined with Name() */ - /* Typechecking for _HID */ + ApCheckForPredefinedObject (Op, Op->Asl.NameSeg); - else if (!ACPI_STRCMP (METHOD_NAME__HID, ReservedMethods[i].Name)) - { - /* Examine the second operand to typecheck it */ + /* Special typechecking for _HID */ - Next = Op->Asl.Child->Asl.Next; + if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) + { + Next = Op->Asl.Child->Asl.Next; + AnCheckId (Next, ASL_TYPE_HID); + } - if ((Next->Asl.ParseOpcode != PARSEOP_INTEGER) && - (Next->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)) - { - /* _HID must be a string or an integer */ + /* Special typechecking for _CID */ - AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, - "String or Integer"); - } + else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) + { + Next = Op->Asl.Child->Asl.Next; - if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) + if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) || + (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) + { + Next = Next->Asl.Child; + while (Next) { - /* - * _HID is a string, all characters must be alphanumeric. - * One of the things we want to catch here is the use of - * a leading asterisk in the string. - */ - for (i = 0; Next->Asl.Value.String[i]; i++) - { - if (!isalnum (Next->Asl.Value.String[i])) - { - AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, - Next, Next->Asl.Value.String); - break; - } - } + AnCheckId (Next, ASL_TYPE_CID); + Next = Next->Asl.Next; } } + else + { + AnCheckId (Next, ASL_TYPE_CID); + } } break; @@ -1253,47 +1702,7 @@ AnMethodAnalysisWalkBegin ( break; } - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnLastStatementIsReturn - * - * PARAMETERS: Op - A method parse node - * - * RETURN: TRUE if last statement is an ASL RETURN. False otherwise - * - * DESCRIPTION: Walk down the list of top level statements within a method - * to find the last one. Check if that last statement is in - * fact a RETURN statement. - * - ******************************************************************************/ - -static BOOLEAN -AnLastStatementIsReturn ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Next; - - - /* - * Check if last statement is a return - */ - Next = ASL_GET_CHILD_NODE (Op); - while (Next) - { - if ((!Next->Asl.Next) && - (Next->Asl.ParseOpcode == PARSEOP_RETURN)) - { - return TRUE; - } - - Next = ASL_GET_PEER_NODE (Next); - } - - return FALSE; + return (AE_OK); } @@ -1329,6 +1738,7 @@ AnMethodAnalysisWalkEnd ( printf ("No method info for method! [%s]\n", Op->Asl.Namepath); AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "No method info for this method"); + CmCleanupAndExit (); return (AE_AML_INTERNAL); } @@ -1394,13 +1804,31 @@ AnMethodAnalysisWalkEnd ( * Check predefined method names for correct return behavior * and correct number of arguments */ - AnCheckForReservedMethod (Op, MethodInfo); + ApCheckForPredefinedMethod (Op, MethodInfo); + + /* Special check for two names like _L01 and _E01 in same scope */ + + ApCheckForGpeNameConflict (Op); ACPI_FREE (MethodInfo); break; + case PARSEOP_NAME: + + /* Special check for two names like _L01 and _E01 in same scope */ + + ApCheckForGpeNameConflict (Op); + break; + + case PARSEOP_RETURN: + /* + * If the parent is a predefined method name, attempt to typecheck + * the return value. Only static types can be validated. + */ + ApCheckPredefinedReturnValue (Op, MethodInfo); + /* * The parent block does not "exit" and continue execution -- the * method is terminated here with the Return() statement. @@ -1465,30 +1893,7 @@ AnMethodAnalysisWalkEnd ( break; } - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnMethodTypingWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the typing walk. - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodTypingWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; + return (AE_OK); } @@ -1545,7 +1950,7 @@ AnMethodTypingWalkEnd ( /* We must type the method here */ TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, - ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, + ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); ThisNodeBtype = AnGetBtype (Op->Asl.Child); @@ -1565,106 +1970,7 @@ AnMethodTypingWalkEnd ( break; } - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnCheckMethodReturnValue - * - * PARAMETERS: Op - Parent - * OpInfo - Parent info - * ArgOp - Method invocation op - * RequiredBtypes - What caller requires - * ThisNodeBtype - What this node returns (if anything) - * - * RETURN: None - * - * DESCRIPTION: Check a method invocation for 1) A return value and if it does - * in fact return a value, 2) check the type of the return value. - * - ******************************************************************************/ - -static void -AnCheckMethodReturnValue ( - ACPI_PARSE_OBJECT *Op, - const ACPI_OPCODE_INFO *OpInfo, - ACPI_PARSE_OBJECT *ArgOp, - UINT32 RequiredBtypes, - UINT32 ThisNodeBtype) -{ - ACPI_PARSE_OBJECT *OwningOp; - ACPI_NAMESPACE_NODE *Node; - - - Node = ArgOp->Asl.Node; - - - /* Examine the parent op of this method */ - - OwningOp = Node->Op; - if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL) - { - /* Method NEVER returns a value */ - - AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName); - } - else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL) - { - /* Method SOMETIMES returns a value, SOMETIMES not */ - - AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); - } - else if (!(ThisNodeBtype & RequiredBtypes)) - { - /* Method returns a value, but the type is wrong */ - - AnFormatBtype (StringBuffer, ThisNodeBtype); - AnFormatBtype (StringBuffer2, RequiredBtypes); - - - /* - * The case where the method does not return any value at all - * was already handled in the namespace cross reference - * -- Only issue an error if the method in fact returns a value, - * but it is of the wrong type - */ - if (ThisNodeBtype != 0) - { - sprintf (MsgBuffer, - "Method returns [%s], %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); - - AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AnOperandTypecheckWalkBegin - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Descending callback for the analysis walk. Check methods for: - * 1) Initialized local variables - * 2) Valid arguments - * 3) Return types - * - ******************************************************************************/ - -ACPI_STATUS -AnOperandTypecheckWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; + return (AE_OK); } @@ -1980,73 +2286,6 @@ AnOperandTypecheckWalkEnd ( } -/******************************************************************************* - * - * FUNCTION: AnIsResultUsed - * - * PARAMETERS: Op - Parent op for the operator - * - * RETURN: TRUE if result from this operation is actually consumed - * - * DESCRIPTION: Determine if the function result value from an operator is - * used. - * - ******************************************************************************/ - -BOOLEAN -AnIsResultUsed ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Parent; - - - switch (Op->Asl.ParseOpcode) - { - case PARSEOP_INCREMENT: - case PARSEOP_DECREMENT: - - /* These are standalone operators, no return value */ - - return (TRUE); - - default: - break; - } - - /* Examine parent to determine if the return value is used */ - - Parent = Op->Asl.Parent; - switch (Parent->Asl.ParseOpcode) - { - /* If/While - check if the operator is the predicate */ - - case PARSEOP_IF: - case PARSEOP_WHILE: - - /* First child is the predicate */ - - if (Parent->Asl.Child == Op) - { - return (TRUE); - } - return (FALSE); - - /* Not used if one of these is the parent */ - - case PARSEOP_METHOD: - case PARSEOP_DEFINITIONBLOCK: - case PARSEOP_ELSE: - - return (FALSE); - - default: - /* Any other type of parent means that the result is used */ - - return (TRUE); - } -} - - /******************************************************************************* * * FUNCTION: AnOtherSemanticAnalysisWalkBegin @@ -2101,14 +2340,17 @@ AnOtherSemanticAnalysisWalkBegin ( if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) { if ((ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) && + (PrevArgNode) && (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); } } else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); } } else @@ -2125,7 +2367,8 @@ AnOtherSemanticAnalysisWalkBegin ( break; default: - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + Op, Op->Asl.ExternalName); break; } } @@ -2157,7 +2400,7 @@ AnOtherSemanticAnalysisWalkBegin ( */ if (((ArgNode->Asl.ParseOpcode == PARSEOP_WORDCONST) || (ArgNode->Asl.ParseOpcode == PARSEOP_INTEGER)) && - (ArgNode->Asl.Value.Integer >= (ACPI_INTEGER) ACPI_WAIT_FOREVER)) + (ArgNode->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) { break; } @@ -2168,7 +2411,8 @@ AnOtherSemanticAnalysisWalkBegin ( */ if (!AnIsResultUsed (Op)) { - AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgNode, + Op->Asl.ExternalName); } break; @@ -2192,68 +2436,5 @@ AnOtherSemanticAnalysisWalkBegin ( break; } - return AE_OK; -} - - -/******************************************************************************* - * - * FUNCTION: AnOtherSemanticAnalysisWalkEnd - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for analysis walk. Complete method - * return analysis. - * - ******************************************************************************/ - -ACPI_STATUS -AnOtherSemanticAnalysisWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - return AE_OK; - -} - - -#ifdef ACPI_OBSOLETE_FUNCTIONS -/******************************************************************************* - * - * FUNCTION: AnMapBtypeToEtype - * - * PARAMETERS: Btype - Bitfield of ACPI types - * - * RETURN: The Etype corresponding the the Btype - * - * DESCRIPTION: Convert a bitfield type to an encoded type - * - ******************************************************************************/ - -UINT32 -AnMapBtypeToEtype ( - UINT32 Btype) -{ - UINT32 i; - UINT32 Etype; - - - if (Btype == 0) - { - return 0; - } - - Etype = 1; - for (i = 1; i < Btype; i *= 2) - { - Etype++; - } - - return (Etype); + return (AE_OK); } -#endif - diff --git a/sys/contrib/dev/acpica-unix/compiler/dtcompile.c b/sys/contrib/dev/acpica-unix/compiler/dtcompile.c new file mode 100644 index 0000000000..c4f73d10e8 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtcompile.c @@ -0,0 +1,658 @@ +/****************************************************************************** + * + * Module Name: dtcompile.c - Front-end for data table compiler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTCOMPILE_C__ +#define _DECLARE_DT_GLOBALS + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtcompile") + +static char VersionString[9]; + + +/* Local prototypes */ + +static ACPI_STATUS +DtInitialize ( + void); + +static ACPI_STATUS +DtCompileDataTable ( + DT_FIELD **Field); + +static void +DtInsertCompilerIds ( + DT_FIELD *FieldList); + + +/****************************************************************************** + * + * FUNCTION: DtDoCompile + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Main entry point for the data table compiler. + * + * Note: Assumes Gbl_Files[ASL_FILE_INPUT] is initialized and the file is + * open at seek offset zero. + * + *****************************************************************************/ + +ACPI_STATUS +DtDoCompile ( + void) +{ + ACPI_STATUS Status; + UINT8 Event; + DT_FIELD *FieldList; + + + /* Initialize globals */ + + Status = DtInitialize (); + if (ACPI_FAILURE (Status)) + { + printf ("Error during compiler initialization, 0x%X\n", Status); + return (Status); + } + + /* + * Scan the input file (file is already open) and + * build the parse tree + */ + Event = UtBeginEvent ("Scan and parse input file"); + FieldList = DtScanFile (Gbl_Files[ASL_FILE_INPUT].Handle); + UtEndEvent (Event); + + /* Did the parse tree get successfully constructed? */ + + if (!FieldList) + { + /* TBD: temporary error message. Msgs should come from function above */ + + DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, + "Input file does not appear to be an ASL or data table source file"); + + Status = AE_ERROR; + goto CleanupAndExit; + } + + Event = UtBeginEvent ("Compile parse tree"); + + /* + * Compile the parse tree + */ + Status = DtCompileDataTable (&FieldList); + UtEndEvent (Event); + + DtFreeFieldList (); + + if (ACPI_FAILURE (Status)) + { + /* TBD: temporary error message. Msgs should come from function above */ + + DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, + "Could not compile input file"); + + goto CleanupAndExit; + } + + /* Create/open the binary output file */ + + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = NULL; + Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); + if (ACPI_FAILURE (Status)) + { + goto CleanupAndExit; + } + + /* Write the binary, then the optional hex file */ + + DtOutputBinary (Gbl_RootTable); + LsDoHexOutput (); + DtWriteTableToListing (); + +CleanupAndExit: + + CmCleanupAndExit (); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize data table compiler globals. Enables multiple + * compiles per invocation. + * + *****************************************************************************/ + +static ACPI_STATUS +DtInitialize ( + void) +{ + ACPI_STATUS Status; + + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Gbl_FieldList = NULL; + Gbl_RootTable = NULL; + Gbl_SubtableStack = NULL; + + sprintf (VersionString, "%X", (UINT32) ACPI_CA_VERSION); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtInsertCompilerIds + * + * PARAMETERS: FieldList - Current field list pointer + * + * RETURN: None + * + * DESCRIPTION: Insert the IDs (Name, Version) of the current compiler into + * the original ACPI table header. + * + *****************************************************************************/ + +static void +DtInsertCompilerIds ( + DT_FIELD *FieldList) +{ + DT_FIELD *Next; + UINT32 i; + + + /* + * Don't insert current compiler ID if requested. Used for compiler + * debug/validation only. + */ + if (Gbl_UseOriginalCompilerId) + { + return; + } + + /* Walk to the Compiler fields at the end of the header */ + + Next = FieldList; + for (i = 0; i < 7; i++) + { + Next = Next->Next; + } + + Next->Value = ASL_CREATOR_ID; + Next->Flags = DT_FIELD_NOT_ALLOCATED; + + Next = Next->Next; + Next->Value = VersionString; + Next->Flags = DT_FIELD_NOT_ALLOCATED; +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDataTable + * + * PARAMETERS: FieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Entry point to compile one data table + * + *****************************************************************************/ + +static ACPI_STATUS +DtCompileDataTable ( + DT_FIELD **FieldList) +{ + ACPI_DMTABLE_DATA *TableData; + DT_SUBTABLE *Subtable; + char *Signature; + ACPI_TABLE_HEADER *AcpiTableHeader; + ACPI_STATUS Status; + + + /* Verify that we at least have a table signature and save it */ + + Signature = DtGetFieldValue (*FieldList, "Signature"); + if (!Signature) + { + sprintf (MsgBuffer, "Expected \"%s\"", "Signature"); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + *FieldList, MsgBuffer); + return (AE_ERROR); + } + + Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); + strcpy (Gbl_Signature, Signature); + + /* + * Handle tables that don't use the common ACPI table header structure. + * Currently, these are the FACS and RSDP. Also check for an OEMx table, + * these tables have user-defined contents. + */ + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) + { + Status = DtCompileFacs (FieldList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtSetTableLength (); + return (Status); + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDP)) + { + Status = DtCompileRsdp (FieldList); + return (Status); + } + else if (!ACPI_STRNCMP (Signature, "OEM", 3)) + { + DtFatal (ASL_MSG_OEM_TABLE, *FieldList, Signature); + return (AE_ERROR); + } + + /* Validate the signature via the ACPI table list */ + + TableData = AcpiDmGetTableData (Signature); + if (!TableData) + { + DtFatal (ASL_MSG_UNKNOWN_TABLE, *FieldList, Signature); + return (AE_ERROR); + } + + /* + * All other tables must use the common ACPI table header. Insert the + * current iASL IDs (name, version), and compile the header now. + */ + DtInsertCompilerIds (*FieldList); + + Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader, + &Gbl_RootTable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtPushSubtable (Gbl_RootTable); + + /* Dispatch to per-table compile */ + + if (TableData->CmTableHandler) + { + /* Complex table, has a handler */ + + Status = TableData->CmTableHandler ((void **) FieldList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else if (TableData->TableInfo) + { + /* Simple table, just walk the info table */ + + Subtable = NULL; + Status = DtCompileTable (FieldList, TableData->TableInfo, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (Gbl_RootTable, Subtable); + DtPopSubtable (); + } + else + { + DtFatal (ASL_MSG_COMPILER_INTERNAL, *FieldList, + "Missing table dispatch info"); + return (AE_ERROR); + } + + /* Set the final table length and then the checksum */ + + DtSetTableLength (); + AcpiTableHeader = ACPI_CAST_PTR ( + ACPI_TABLE_HEADER, Gbl_RootTable->Buffer); + DtSetTableChecksum (&AcpiTableHeader->Checksum); + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileTable + * + * PARAMETERS: Field - Current field list pointer + * Info - Info table for this ACPI table + * RetSubtable - Compile result of table + * Required - If this subtable must exist + * + * RETURN: Status + * + * DESCRIPTION: Compile a subtable + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileTable ( + DT_FIELD **Field, + ACPI_DMTABLE_INFO *Info, + DT_SUBTABLE **RetSubtable, + BOOLEAN Required) +{ + DT_FIELD *LocalField; + UINT32 Length; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *InlineSubtable; + UINT32 FieldLength = 0; + UINT8 FieldType; + UINT8 *Buffer; + UINT8 *FlagBuffer = NULL; + ACPI_STATUS Status; + + + if (!Field || !*Field) + { + return (AE_BAD_PARAMETER); + } + + Length = DtGetSubtableLength (*Field, Info); + Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + + if (Length > 0) + { + Subtable->Buffer = UtLocalCalloc (Length); + } + Subtable->Length = Length; + Subtable->TotalLength = Length; + Buffer = Subtable->Buffer; + + LocalField = *Field; + + /* + * Main loop walks the info table for this ACPI table or subtable + */ + for (; Info->Name; Info++) + { + if (!LocalField) + { + sprintf (MsgBuffer, "Found NULL field - Field name \"%s\" needed", + Info->Name); + DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); + Status = AE_BAD_DATA; + goto Error; + } + + /* Does input field name match what is expected? */ + + if (ACPI_STRCMP (LocalField->Name, Info->Name)) + { + /* + * If Required = TRUE, the subtable must exist. + * If Required = FALSE, the subtable is optional + * (For example, AcpiDmTableInfoDmarScope in DMAR table is + * optional) + */ + if (Required) + { + sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + LocalField, MsgBuffer); + } + else + { + Status = AE_NOT_FOUND; + goto Error; + } + } + + /* Maintain table offsets */ + + LocalField->TableOffset = Gbl_CurrentTableOffset; + FieldLength = DtGetFieldLength (LocalField, Info); + Gbl_CurrentTableOffset += FieldLength; + + FieldType = DtGetFieldType (Info); + Gbl_InputFieldCount++; + + switch (FieldType) + { + case DT_FIELD_TYPE_FLAGS_INTEGER: + /* + * Start of the definition of a flags field. + * This master flags integer starts at value zero, in preparation + * to compile and insert the flag fields from the individual bits + */ + LocalField = LocalField->Next; + *Field = LocalField; + + FlagBuffer = Buffer; + break; + + case DT_FIELD_TYPE_FLAG: + + /* Individual Flag field, can be multiple bits */ + + if (FlagBuffer) + { + DtCompileFlag (FlagBuffer, LocalField, Info); + } + else + { + /* TBD - this is an internal error */ + } + + LocalField = LocalField->Next; + *Field = LocalField; + break; + + case DT_FIELD_TYPE_INLINE_SUBTABLE: + /* + * Recursion (one level max): compile GAS (Generic Address) + * or Notify in-line subtable + */ + LocalField = LocalField->Next; + *Field = LocalField; + + if (Info->Opcode == ACPI_DMT_GAS) + { + Status = DtCompileTable (Field, AcpiDmTableInfoGas, + &InlineSubtable, TRUE); + } + else + { + Status = DtCompileTable (Field, AcpiDmTableInfoHestNotify, + &InlineSubtable, TRUE); + } + + if (ACPI_FAILURE (Status)) + { + goto Error; + } + + DtSetSubtableLength (InlineSubtable); + + ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); + ACPI_FREE (InlineSubtable->Buffer); + ACPI_FREE (InlineSubtable); + LocalField = *Field; + break; + + case DT_FIELD_TYPE_LABEL: + + DtWriteFieldToListing (Buffer, LocalField, 0); + LocalField = LocalField->Next; + break; + + default: + + /* Normal case for most field types (Integer, String, etc.) */ + + DtCompileOneField (Buffer, LocalField, + FieldLength, FieldType, Info->Flags); + + DtWriteFieldToListing (Buffer, LocalField, FieldLength); + LocalField = LocalField->Next; + + if (Info->Flags & DT_LENGTH) + { + /* Field is an Integer that will contain a subtable length */ + + Subtable->LengthField = Buffer; + Subtable->SizeOfLengthField = FieldLength; + } + + break; + } + + Buffer += FieldLength; + } + + *Field = LocalField; + *RetSubtable = Subtable; + return (AE_OK); + +Error: + ACPI_FREE (Subtable->Buffer); + ACPI_FREE (Subtable); + return (Status); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/dtcompiler.h b/sys/contrib/dev/acpica-unix/compiler/dtcompiler.h new file mode 100644 index 0000000000..581ce0bbf4 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtcompiler.h @@ -0,0 +1,526 @@ +/****************************************************************************** + * + * Module Name: dtcompiler.h - header for data table compiler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTCOMPILER_H__ + +#ifndef _DTCOMPILER +#define _DTCOMPILER + +#include +#include "acdisasm.h" + + +#undef DT_EXTERN + +#ifdef _DECLARE_DT_GLOBALS +#define DT_EXTERN +#define DT_INIT_GLOBAL(a,b) (a)=(b) +#else +#define DT_EXTERN extern +#define DT_INIT_GLOBAL(a,b) (a) +#endif + + +/* Types for individual fields (one per input line) */ + +#define DT_FIELD_TYPE_STRING 0 +#define DT_FIELD_TYPE_INTEGER 1 +#define DT_FIELD_TYPE_BUFFER 2 +#define DT_FIELD_TYPE_PCI_PATH 3 +#define DT_FIELD_TYPE_FLAG 4 +#define DT_FIELD_TYPE_FLAGS_INTEGER 5 +#define DT_FIELD_TYPE_INLINE_SUBTABLE 6 +#define DT_FIELD_TYPE_UUID 7 +#define DT_FIELD_TYPE_UNICODE 8 +#define DT_FIELD_TYPE_DEVICE_PATH 9 +#define DT_FIELD_TYPE_LABEL 10 + + +/* + * Structure used for each individual field within an ACPI table + */ +typedef struct dt_field +{ + char *Name; /* Field name (from name : value) */ + char *Value; /* Field value (from name : value) */ + struct dt_field *Next; /* Next field */ + struct dt_field *NextLabel; /* If field is a label, next label */ + UINT32 Line; /* Line number for this field */ + UINT32 ByteOffset; /* Offset in source file for field */ + UINT32 NameColumn; /* Start column for field name */ + UINT32 Column; /* Start column for field value */ + UINT32 TableOffset;/* Binary offset within ACPI table */ + UINT8 Flags; + +} DT_FIELD; + +/* Flags for above */ + +#define DT_FIELD_NOT_ALLOCATED 1 + + +/* + * Structure used for individual subtables within an ACPI table + */ +typedef struct dt_subtable +{ + struct dt_subtable *Parent; + struct dt_subtable *Child; + struct dt_subtable *Peer; + struct dt_subtable *StackTop; + UINT8 *Buffer; + UINT8 *LengthField; + UINT32 Length; + UINT32 TotalLength; + UINT32 SizeOfLengthField; + UINT8 Flags; + +} DT_SUBTABLE; + + +/* + * Globals + */ + +/* List of all field names and values from the input source */ + +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldList, NULL); + +/* List of all compiled tables and subtables */ + +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_RootTable, NULL); + +/* Stack for subtables */ + +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL); + +/* List for defined labels */ + +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL); + +/* Current offset within the binary output table */ + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0); + + +/* dtcompiler - main module */ + +ACPI_STATUS +DtCompileTable ( + DT_FIELD **Field, + ACPI_DMTABLE_INFO *Info, + DT_SUBTABLE **RetSubtable, + BOOLEAN Required); + + +/* dtio - binary and text input/output */ + +DT_FIELD * +DtScanFile ( + FILE *Handle); + +void +DtOutputBinary ( + DT_SUBTABLE *RootTable); + +void +DtWriteFieldToListing ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 Length); + +void +DtWriteTableToListing ( + void); + + +/* dtsubtable - compile subtables */ + +void +DtCreateSubtable ( + UINT8 *Buffer, + UINT32 Length, + DT_SUBTABLE **RetSubtable); + +UINT32 +DtGetSubtableLength ( + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info); + +void +DtSetSubtableLength ( + DT_SUBTABLE *Subtable); + +void +DtPushSubtable ( + DT_SUBTABLE *Subtable); + +void +DtPopSubtable ( + void); + +DT_SUBTABLE * +DtPeekSubtable ( + void); + +void +DtInsertSubtable ( + DT_SUBTABLE *ParentTable, + DT_SUBTABLE *Subtable); + +DT_SUBTABLE * +DtGetNextSubtable ( + DT_SUBTABLE *ParentTable, + DT_SUBTABLE *ChildTable); + +DT_SUBTABLE * +DtGetParentSubtable ( + DT_SUBTABLE *Subtable); + + +/* dtexpress - Integer expressions and labels */ + +UINT64 +DtResolveIntegerExpression ( + DT_FIELD *Field); + +void +DtDetectAllLabels ( + DT_FIELD *FieldList); + + +/* dtfield - Compile individual fields within a table */ + +void +DtCompileOneField ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength, + UINT8 Type, + UINT8 Flags); + +void +DtCompileInteger ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength, + UINT8 Flags); + +UINT32 +DtCompileBuffer ( + UINT8 *Buffer, + char *Value, + DT_FIELD *Field, + UINT32 ByteLength); + +void +DtCompileFlag ( + UINT8 *Buffer, + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info); + + +/* dtutils - Miscellaneous utilities */ + +typedef +void (*DT_WALK_CALLBACK) ( + DT_SUBTABLE *Subtable, + void *Context, + void *ReturnValue); + +void +DtWalkTableTree ( + DT_SUBTABLE *StartTable, + DT_WALK_CALLBACK UserFunction, + void *Context, + void *ReturnValue); + +void +DtError ( + UINT8 Level, + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage); + +void +DtNameError ( + UINT8 Level, + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage); + +void +DtFatal ( + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage); + +ACPI_STATUS +DtStrtoul64 ( + char *String, + UINT64 *ReturnInteger); + +UINT32 +DtGetFileSize ( + FILE *Handle); + +char* +DtGetFieldValue ( + DT_FIELD *Field, + char *Name); + +UINT8 +DtGetFieldType ( + ACPI_DMTABLE_INFO *Info); + +UINT32 +DtGetBufferLength ( + char *Buffer); + +UINT32 +DtGetFieldLength ( + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info); + +void +DtSetTableChecksum ( + UINT8 *ChecksumPointer); + +void +DtSetTableLength( + void); + +void +DtFreeFieldList ( + void); + + +/* dttable - individual table compilation */ + +ACPI_STATUS +DtCompileFacs ( + DT_FIELD **PFieldList); + +ACPI_STATUS +DtCompileRsdp ( + DT_FIELD **PFieldList); + +ACPI_STATUS +DtCompileAsf ( + void **PFieldList); + +ACPI_STATUS +DtCompileCpep ( + void **PFieldList); + +ACPI_STATUS +DtCompileDmar ( + void **PFieldList); + +ACPI_STATUS +DtCompileEinj ( + void **PFieldList); + +ACPI_STATUS +DtCompileErst ( + void **PFieldList); + +ACPI_STATUS +DtCompileFadt ( + void **PFieldList); + +ACPI_STATUS +DtCompileHest ( + void **PFieldList); + +ACPI_STATUS +DtCompileIvrs ( + void **PFieldList); + +ACPI_STATUS +DtCompileMadt ( + void **PFieldList); + +ACPI_STATUS +DtCompileMcfg ( + void **PFieldList); + +ACPI_STATUS +DtCompileMsct ( + void **PFieldList); + +ACPI_STATUS +DtCompileRsdt ( + void **PFieldList); + +ACPI_STATUS +DtCompileSlit ( + void **PFieldList); + +ACPI_STATUS +DtCompileSrat ( + void **PFieldList); + +ACPI_STATUS +DtCompileUefi ( + void **PFieldList); + +ACPI_STATUS +DtCompileWdat ( + void **PFieldList); + +ACPI_STATUS +DtCompileXsdt ( + void **PFieldList); + +ACPI_DMTABLE_INFO * +DtGetGenericTableInfo ( + char *Name); + +/* ACPI Table templates */ + +extern const unsigned char TemplateAsf[]; +extern const unsigned char TemplateBoot[]; +extern const unsigned char TemplateBert[]; +extern const unsigned char TemplateCpep[]; +extern const unsigned char TemplateDbgp[]; +extern const unsigned char TemplateDmar[]; +extern const unsigned char TemplateEcdt[]; +extern const unsigned char TemplateEinj[]; +extern const unsigned char TemplateErst[]; +extern const unsigned char TemplateFadt[]; +extern const unsigned char TemplateHest[]; +extern const unsigned char TemplateHpet[]; +extern const unsigned char TemplateIvrs[]; +extern const unsigned char TemplateMadt[]; +extern const unsigned char TemplateMcfg[]; +extern const unsigned char TemplateMchi[]; +extern const unsigned char TemplateMsct[]; +extern const unsigned char TemplateRsdt[]; +extern const unsigned char TemplateSbst[]; +extern const unsigned char TemplateSlic[]; +extern const unsigned char TemplateSlit[]; +extern const unsigned char TemplateSpcr[]; +extern const unsigned char TemplateSpmi[]; +extern const unsigned char TemplateSrat[]; +extern const unsigned char TemplateTcpa[]; +extern const unsigned char TemplateUefi[]; +extern const unsigned char TemplateWaet[]; +extern const unsigned char TemplateWdat[]; +extern const unsigned char TemplateWddt[]; +extern const unsigned char TemplateWdrt[]; +extern const unsigned char TemplateXsdt[]; + +#endif diff --git a/sys/contrib/dev/acpica-unix/compiler/dtexpress.c b/sys/contrib/dev/acpica-unix/compiler/dtexpress.c new file mode 100644 index 0000000000..b923a1d716 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtexpress.c @@ -0,0 +1,462 @@ +/****************************************************************************** + * + * Module Name: dtexpress.c - Support for integer expressions and labels + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTEXPRESS_C__ + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtexpress") + + +/* Local prototypes */ + +static UINT64 +DtResolveInteger ( + DT_FIELD *Field, + char *IntegerString); + +static void +DtInsertLabelField ( + DT_FIELD *Field); + +static DT_FIELD * +DtLookupLabel ( + char *Name); + + +/****************************************************************************** + * + * FUNCTION: DtResolveIntegerExpression + * + * PARAMETERS: Field - Field object with Integer expression + * + * RETURN: A 64-bit integer value + * + * DESCRIPTION: Resolve an integer expression to a single value. Supports + * both integer constants and labels. Supported operators are: + * +,-,*,/,%,|,&,^ + * + *****************************************************************************/ + +UINT64 +DtResolveIntegerExpression ( + DT_FIELD *Field) +{ + char *IntegerString; + char *Operator; + UINT64 Value; + UINT64 Value2; + + + DbgPrint (ASL_DEBUG_OUTPUT, "Full Integer expression: %s\n", + Field->Value); + + strcpy (MsgBuffer, Field->Value); /* Must take a copy for strtok() */ + + /* Obtain and resolve the first operand */ + + IntegerString = strtok (MsgBuffer, " "); + if (!IntegerString) + { + DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value); + return (0); + } + + Value = DtResolveInteger (Field, IntegerString); + DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V1: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Value)); + + /* + * Consume the entire expression string. For the rest of the + * expression string, values are of the form: + * + */ + while (1) + { + Operator = strtok (NULL, " "); + if (!Operator) + { + /* Normal exit */ + + DbgPrint (ASL_DEBUG_OUTPUT, "Expression Resolved to: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Value)); + + return (Value); + } + + IntegerString = strtok (NULL, " "); + if (!IntegerString || + (strlen (Operator) > 1)) + { + /* No corresponding operand for operator or invalid operator */ + + DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value); + return (0); + } + + Value2 = DtResolveInteger (Field, IntegerString); + DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V2: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Value2)); + + /* Perform the requested operation */ + + switch (*Operator) + { + case '-': + Value -= Value2; + break; + + case '+': + Value += Value2; + break; + + case '*': + Value *= Value2; + break; + + case '|': + Value |= Value2; + break; + + case '&': + Value &= Value2; + break; + + case '^': + Value ^= Value2; + break; + + case '/': + if (!Value2) + { + DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value); + return (0); + } + Value /= Value2; + break; + + case '%': + if (!Value2) + { + DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value); + return (0); + } + Value %= Value2; + break; + + default: + + /* Unknown operator */ + + DtFatal (ASL_MSG_INVALID_EXPRESSION, Field, Field->Value); + break; + } + } + + return (Value); +} + + +/****************************************************************************** + * + * FUNCTION: DtResolveInteger + * + * PARAMETERS: Field - Field object with string to be resolved + * IntegerString - Integer to be resolved + * + * RETURN: A 64-bit integer value + * + * DESCRIPTION: Resolve a single integer string to a value. Supports both + * integer constants and labels. + * + * NOTE: References to labels must begin with a dollar sign ($) + * + *****************************************************************************/ + +static UINT64 +DtResolveInteger ( + DT_FIELD *Field, + char *IntegerString) +{ + DT_FIELD *LabelField; + UINT64 Value = 0; + char *Message = NULL; + ACPI_STATUS Status; + + + DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Integer: %s\n", IntegerString); + + /* Resolve a label reference to an integer (table offset) */ + + if (*IntegerString == '$') + { + LabelField = DtLookupLabel (IntegerString); + if (!LabelField) + { + DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL, Field, IntegerString); + return (0); + } + + /* All we need from the label is the offset in the table */ + + Value = LabelField->TableOffset; + return (Value); + } + + /* Convert string to an actual integer */ + + Status = DtStrtoul64 (IntegerString, &Value); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_LIMIT) + { + Message = "Constant larger than 64 bits"; + } + else if (Status == AE_BAD_CHARACTER) + { + Message = "Invalid character in constant"; + } + + DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, Message); + } + + return (Value); +} + + +/****************************************************************************** + * + * FUNCTION: DtDetectAllLabels + * + * PARAMETERS: FieldList - Field object at start of generic list + * + * RETURN: None + * + * DESCRIPTION: Detect all labels in a list of "generic" opcodes (such as + * a UEFI table.) and insert them into the global label list. + * + *****************************************************************************/ + +void +DtDetectAllLabels ( + DT_FIELD *FieldList) +{ + ACPI_DMTABLE_INFO *Info; + DT_FIELD *GenericField; + UINT32 TableOffset; + + + TableOffset = Gbl_CurrentTableOffset; + GenericField = FieldList; + + /* + * Process all "Label:" fields within the parse tree. We need + * to know the offsets for all labels before we can compile + * the parse tree in order to handle forward references. Traverse + * tree and get/set all field lengths of all operators in order to + * determine the label offsets. + */ + while (GenericField) + { + Info = DtGetGenericTableInfo (GenericField->Name); + if (Info) + { + /* Maintain table offsets */ + + GenericField->TableOffset = TableOffset; + TableOffset += DtGetFieldLength (GenericField, Info); + + /* Insert all labels in the global label list */ + + if (Info->Opcode == ACPI_DMT_LABEL) + { + DtInsertLabelField (GenericField); + } + } + + GenericField = GenericField->Next; + } +} + + +/****************************************************************************** + * + * FUNCTION: DtInsertLabelField + * + * PARAMETERS: Field - Field object with Label to be inserted + * + * RETURN: None + * + * DESCRIPTION: Insert a label field into the global label list + * + *****************************************************************************/ + +static void +DtInsertLabelField ( + DT_FIELD *Field) +{ + + DbgPrint (ASL_DEBUG_OUTPUT, + "DtInsertLabelField: Found Label : %s at output table offset %X\n", + Field->Value, Field->TableOffset); + + Field->NextLabel = Gbl_LabelList; + Gbl_LabelList = Field; +} + + +/****************************************************************************** + * + * FUNCTION: DtLookupLabel + * + * PARAMETERS: Name - Label to be resolved + * + * RETURN: Field object associated with the label + * + * DESCRIPTION: Lookup a label in the global label list. Used during the + * resolution of integer expressions. + * + *****************************************************************************/ + +static DT_FIELD * +DtLookupLabel ( + char *Name) +{ + DT_FIELD *LabelField; + + + /* Skip a leading $ */ + + if (*Name == '$') + { + Name++; + } + + /* Search global list */ + + LabelField = Gbl_LabelList; + while (LabelField) + { + if (!ACPI_STRCMP (Name, LabelField->Value)) + { + return (LabelField); + } + LabelField = LabelField->NextLabel; + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/dtfield.c b/sys/contrib/dev/acpica-unix/compiler/dtfield.c new file mode 100644 index 0000000000..35fa067b3a --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtfield.c @@ -0,0 +1,615 @@ +/****************************************************************************** + * + * Module Name: dtfield.c - Code generation for individual source fields + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTFIELD_C__ + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtfield") + + +/* Local prototypes */ + +static void +DtCompileString ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength); + +static void +DtCompileUnicode ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength); + +static ACPI_STATUS +DtCompileUuid ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength); + +static char * +DtNormalizeBuffer ( + char *Buffer, + UINT32 *Count); + + +/****************************************************************************** + * + * FUNCTION: DtCompileOneField + * + * PARAMETERS: Buffer - Output buffer + * Field - Field to be compiled + * ByteLength - Byte length of the field + * Type - Field type + * + * RETURN: None + * + * DESCRIPTION: Compile a field value to binary + * + *****************************************************************************/ + +void +DtCompileOneField ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength, + UINT8 Type, + UINT8 Flags) +{ + ACPI_STATUS Status; + + switch (Type) + { + case DT_FIELD_TYPE_INTEGER: + DtCompileInteger (Buffer, Field, ByteLength, Flags); + break; + + case DT_FIELD_TYPE_STRING: + DtCompileString (Buffer, Field, ByteLength); + break; + + case DT_FIELD_TYPE_UUID: + Status = DtCompileUuid (Buffer, Field, ByteLength); + if (ACPI_SUCCESS (Status)) + { + break; + } + + /* Fall through. */ + + case DT_FIELD_TYPE_BUFFER: + DtCompileBuffer (Buffer, Field->Value, Field, ByteLength); + break; + + case DT_FIELD_TYPE_UNICODE: + DtCompileUnicode (Buffer, Field, ByteLength); + break; + + case DT_FIELD_TYPE_DEVICE_PATH: + break; + + default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid field type"); + break; + } +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileString + * + * PARAMETERS: Buffer - Output buffer + * Field - String to be copied to buffer + * ByteLength - Maximum length of string + * + * RETURN: None + * + * DESCRIPTION: Copy string to the buffer + * + *****************************************************************************/ + +static void +DtCompileString ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength) +{ + UINT32 Length; + + + Length = ACPI_STRLEN (Field->Value); + + /* Check if the string is too long for the field */ + + if (Length > ByteLength) + { + sprintf (MsgBuffer, "Maximum %u characters", ByteLength); + DtError (ASL_ERROR, ASL_MSG_STRING_LENGTH, Field, MsgBuffer); + Length = ByteLength; + } + + ACPI_MEMCPY (Buffer, Field->Value, Length); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileUnicode + * + * PARAMETERS: Buffer - Output buffer + * Field - String to be copied to buffer + * ByteLength - Maximum length of string + * + * RETURN: None + * + * DESCRIPTION: Convert ASCII string to Unicode string + * + * Note: The Unicode string is 16 bits per character, no leading signature, + * with a 16-bit terminating NULL. + * + *****************************************************************************/ + +static void +DtCompileUnicode ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength) +{ + UINT32 Count; + UINT32 i; + char *AsciiString; + UINT16 *UnicodeString; + + + AsciiString = Field->Value; + UnicodeString = (UINT16 *) Buffer; + Count = ACPI_STRLEN (AsciiString) + 1; + + /* Convert to Unicode string (including null terminator) */ + + for (i = 0; i < Count; i++) + { + UnicodeString[i] = (UINT16) AsciiString[i]; + } +} + + +/******************************************************************************* + * + * FUNCTION: DtCompileUuid + * + * PARAMETERS: Buffer - Output buffer + * Field - String to be copied to buffer + * ByteLength - Maximum length of string + * + * RETURN: None + * + * DESCRIPTION: Convert UUID string to 16-byte buffer + * + ******************************************************************************/ + +static ACPI_STATUS +DtCompileUuid ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength) +{ + char *InString; + ACPI_STATUS Status; + + + InString = Field->Value; + + Status = AuValidateUuid (InString); + if (ACPI_FAILURE (Status)) + { + sprintf (MsgBuffer, "%s", Field->Value); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_UUID, Field, MsgBuffer); + } + else + { + Status = AuConvertStringToUuid (InString, (char *) Buffer); + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileInteger + * + * PARAMETERS: Buffer - Output buffer + * Field - Field obj with Integer to be compiled + * ByteLength - Byte length of the integer + * Flags - Additional compile info + * + * RETURN: None + * + * DESCRIPTION: Compile an integer. Supports integer expressions with C-style + * operators. + * + *****************************************************************************/ + +void +DtCompileInteger ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 ByteLength, + UINT8 Flags) +{ + UINT64 Value; + UINT64 MaxValue; + + + /* Output buffer byte length must be in range 1-8 */ + + if ((ByteLength > 8) || (ByteLength == 0)) + { + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, + "Invalid internal Byte length"); + return; + } + + /* Resolve integer expression to a single integer value */ + + Value = DtResolveIntegerExpression (Field); + + /* Ensure that reserved fields are set to zero */ + /* TBD: should we set to zero, or just make this an ERROR? */ + /* TBD: Probably better to use a flag */ + + if (!ACPI_STRCMP (Field->Name, "Reserved") && + (Value != 0)) + { + DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, + "Setting to zero"); + Value = 0; + } + + /* Check if the value must be non-zero */ + + if ((Value == 0) && (Flags & DT_NON_ZERO)) + { + DtError (ASL_ERROR, ASL_MSG_ZERO_VALUE, Field, NULL); + } + + /* + * Generate the maximum value for the data type (ByteLength) + * Note: construct chosen for maximum portability + */ + MaxValue = ((UINT64) (-1)) >> (64 - (ByteLength * 8)); + + /* Validate that the input value is within range of the target */ + + if (Value > MaxValue) + { + sprintf (MsgBuffer, "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Value)); + DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); + } + + ACPI_MEMCPY (Buffer, &Value, ByteLength); + return; +} + + +/****************************************************************************** + * + * FUNCTION: DtNormalizeBuffer + * + * PARAMETERS: Buffer - Input buffer + * Count - Output the count of hex number in + * the Buffer + * + * RETURN: The normalized buffer, freed by caller + * + * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized + * to 1A 2B 3C 4D + * + *****************************************************************************/ + +static char * +DtNormalizeBuffer ( + char *Buffer, + UINT32 *Count) +{ + char *NewBuffer; + char *TmpBuffer; + UINT32 BufferCount = 0; + BOOLEAN Separator = TRUE; + char c; + + + NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1); + TmpBuffer = NewBuffer; + + while ((c = *Buffer++)) + { + switch (c) + { + /* Valid separators */ + + case '[': + case ']': + case ' ': + case ',': + Separator = TRUE; + break; + + default: + if (Separator) + { + /* Insert blank as the standard separator */ + + if (NewBuffer[0]) + { + *TmpBuffer++ = ' '; + BufferCount++; + } + + Separator = FALSE; + } + + *TmpBuffer++ = c; + break; + } + } + + *Count = BufferCount + 1; + return (NewBuffer); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileBuffer + * + * PARAMETERS: Buffer - Output buffer + * StringValue - Integer list to be compiled + * Field - Current field object + * ByteLength - Byte length of the integer list + * + * RETURN: Count of remaining data in the input list + * + * DESCRIPTION: Compile and pack an integer list, for example + * "AA 1F 20 3B" ==> Buffer[] = {0xAA,0x1F,0x20,0x3B} + * + *****************************************************************************/ + +UINT32 +DtCompileBuffer ( + UINT8 *Buffer, + char *StringValue, + DT_FIELD *Field, + UINT32 ByteLength) +{ + ACPI_STATUS Status; + char Hex[3]; + UINT64 Value; + UINT32 i; + UINT32 Count; + + + /* Allow several different types of value separators */ + + StringValue = DtNormalizeBuffer (StringValue, &Count); + + Hex[2] = 0; + for (i = 0; i < Count; i++) + { + /* Each element of StringValue is three chars */ + + Hex[0] = StringValue[(3 * i)]; + Hex[1] = StringValue[(3 * i) + 1]; + + /* Convert one hex byte */ + + Value = 0; + Status = DtStrtoul64 (Hex, &Value); + if (ACPI_FAILURE (Status)) + { + DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer); + return (ByteLength - Count); + } + + Buffer[i] = (UINT8) Value; + } + + ACPI_FREE (StringValue); + return (ByteLength - Count); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileFlag + * + * PARAMETERS: Buffer - Output buffer + * Field - Field to be compiled + * Info - Flag info + * + * RETURN: + * + * DESCRIPTION: Compile a flag + * + *****************************************************************************/ + +void +DtCompileFlag ( + UINT8 *Buffer, + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info) +{ + UINT64 Value = 0; + UINT32 BitLength = 1; + UINT8 BitPosition = 0; + ACPI_STATUS Status; + + + Status = DtStrtoul64 (Field->Value, &Value); + if (ACPI_FAILURE (Status)) + { + DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, NULL); + } + + switch (Info->Opcode) + { + case ACPI_DMT_FLAG0: + case ACPI_DMT_FLAG1: + case ACPI_DMT_FLAG2: + case ACPI_DMT_FLAG3: + case ACPI_DMT_FLAG4: + case ACPI_DMT_FLAG5: + case ACPI_DMT_FLAG6: + case ACPI_DMT_FLAG7: + + BitPosition = Info->Opcode; + BitLength = 1; + break; + + case ACPI_DMT_FLAGS0: + + BitPosition = 0; + BitLength = 2; + break; + + + case ACPI_DMT_FLAGS2: + + BitPosition = 2; + BitLength = 2; + break; + + default: + + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid flag opcode"); + break; + } + + /* Check range of the input flag value */ + + if (Value >= ((UINT64) 1 << BitLength)) + { + sprintf (MsgBuffer, "Maximum %u bit", BitLength); + DtError (ASL_ERROR, ASL_MSG_FLAG_VALUE, Field, MsgBuffer); + Value = 0; + } + + *Buffer |= (UINT8) (Value << BitPosition); +} diff --git a/sys/contrib/dev/acpica-unix/compiler/dtio.c b/sys/contrib/dev/acpica-unix/compiler/dtio.c new file mode 100644 index 0000000000..f3a0c8ecb8 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtio.c @@ -0,0 +1,934 @@ +/****************************************************************************** + * + * Module Name: dtio.c - File I/O support for data table compiler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTIO_C__ + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtio") + + +/* Local prototypes */ + +static char * +DtTrim ( + char *String); + +static void +DtLinkField ( + DT_FIELD *Field); + +static ACPI_STATUS +DtParseLine ( + char *LineBuffer, + UINT32 Line, + UINT32 Offset); + +UINT32 +DtGetNextLine ( + FILE *Handle); + +static void +DtWriteBinary ( + DT_SUBTABLE *Subtable, + void *Context, + void *ReturnValue); + +static void +DtDumpBuffer ( + UINT32 FileId, + UINT8 *Buffer, + UINT32 Offset, + UINT32 Length); + + +/* States for DtGetNextLine */ + +#define DT_NORMAL_TEXT 0 +#define DT_START_QUOTED_STRING 1 +#define DT_START_COMMENT 2 +#define DT_SLASH_ASTERISK_COMMENT 3 +#define DT_SLASH_SLASH_COMMENT 4 +#define DT_END_COMMENT 5 + +static UINT32 Gbl_NextLineOffset; + + +/****************************************************************************** + * + * FUNCTION: DtTrim + * + * PARAMETERS: String - Current source code line to trim + * + * RETURN: Trimmed line. Must be freed by caller. + * + * DESCRIPTION: Trim left and right spaces + * + *****************************************************************************/ + +static char * +DtTrim ( + char *String) +{ + char *Start; + char *End; + char *ReturnString; + ACPI_SIZE Length; + + + /* Skip lines that start with a space */ + + if (!ACPI_STRCMP (String, " ")) + { + ReturnString = UtLocalCalloc (1); + return (ReturnString); + } + + /* Setup pointers to start and end of input string */ + + Start = String; + End = String + ACPI_STRLEN (String) - 1; + + /* Find first non-whitespace character */ + + while ((Start <= End) && ((*Start == ' ') || (*Start == '\t'))) + { + Start++; + } + + /* Find last non-space character */ + + while (End >= Start) + { + if (*End == '\r' || *End == '\n') + { + End--; + continue; + } + + if (*End != ' ') + { + break; + } + + End--; + } + + /* Remove any quotes around the string */ + + if (*Start == '\"') + { + Start++; + } + if (*End == '\"') + { + End--; + } + + /* Create the trimmed return string */ + + Length = ACPI_PTR_DIFF (End, Start) + 1; + ReturnString = UtLocalCalloc (Length + 1); + if (ACPI_STRLEN (Start)) + { + ACPI_STRNCPY (ReturnString, Start, Length); + } + + ReturnString[Length] = 0; + return (ReturnString); +} + + +/****************************************************************************** + * + * FUNCTION: DtLinkField + * + * PARAMETERS: Field - New field object to link + * + * RETURN: None + * + * DESCRIPTION: Link one field name and value to the list + * + *****************************************************************************/ + +static void +DtLinkField ( + DT_FIELD *Field) +{ + DT_FIELD *Prev; + DT_FIELD *Next; + + + Prev = Next = Gbl_FieldList; + + while (Next) + { + Prev = Next; + Next = Next->Next; + } + + if (Prev) + { + Prev->Next = Field; + } + else + { + Gbl_FieldList = Field; + } +} + + +/****************************************************************************** + * + * FUNCTION: DtParseLine + * + * PARAMETERS: LineBuffer - Current source code line + * Line - Current line number in the source + * Offset - Current byte offset of the line + * + * RETURN: Status + * + * DESCRIPTION: Parse one source line + * + *****************************************************************************/ + +static ACPI_STATUS +DtParseLine ( + char *LineBuffer, + UINT32 Line, + UINT32 Offset) +{ + char *Start; + char *End; + char *TmpName; + char *TmpValue; + char *Name; + char *Value; + char *Colon; + UINT32 Length; + DT_FIELD *Field; + UINT32 Column; + UINT32 NameColumn; + + + if (!LineBuffer) + { + return (AE_OK); + } + + /* All lines after "Raw Table Data" are ingored */ + + if (strstr (LineBuffer, ACPI_RAW_TABLE_DATA_HEADER)) + { + return (AE_NOT_FOUND); + } + + Colon = strchr (LineBuffer, ':'); + if (!Colon) + { + return (AE_OK); + } + + Start = LineBuffer; + End = Colon; + + while (Start < Colon) + { + if (*Start == ' ') + { + Start++; + continue; + } + + /* Found left bracket, go to the right bracket */ + + if (*Start == '[') + { + while (Start < Colon && *Start != ']') + { + Start++; + } + + if (Start == Colon) + { + break; + } + + Start++; + continue; + } + + break; + } + + /* + * There are two column values. One for the field name, + * and one for the field value. + */ + Column = ACPI_PTR_DIFF (Colon, LineBuffer) + 3; + NameColumn = ACPI_PTR_DIFF (Start, LineBuffer) + 1; + + Length = ACPI_PTR_DIFF (End, Start); + + TmpName = UtLocalCalloc (Length + 1); + ACPI_STRNCPY (TmpName, Start, Length); + Name = DtTrim (TmpName); + ACPI_FREE (TmpName); + + Start = End = (Colon + 1); + + while (*End) + { + /* Found left quotation, go to the right quotation and break */ + + if (*End == '"') + { + End++; + while (*End && (*End != '"')) + { + End++; + } + + End++; + break; + } + + /* + * Special "comment" fields at line end, ignore them. + * Note: normal slash-slash and slash-asterisk comments are + * stripped already by the DtGetNextLine parser. + * + * TBD: Perhaps DtGetNextLine should parse the following type + * of comments also. + */ + if (*End == '(' || + *End == '<') + { + break; + } + + End++; + } + + Length = ACPI_PTR_DIFF (End, Start); + TmpValue = UtLocalCalloc (Length + 1); + ACPI_STRNCPY (TmpValue, Start, Length); + Value = DtTrim (TmpValue); + ACPI_FREE (TmpValue); + + if (Name && Value) + { + Field = UtLocalCalloc (sizeof (DT_FIELD)); + Field->Name = Name; + Field->Value = Value; + Field->Line = Line; + Field->ByteOffset = Offset; + Field->NameColumn = NameColumn; + Field->Column = Column; + + DtLinkField (Field); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetNextLine + * + * PARAMETERS: Handle - Open file handle for the source file + * + * RETURN: Filled line buffer and offset of start-of-line (zero on EOF) + * + * DESCRIPTION: Get the next valid source line. Removes all comments. + * Ignores empty lines. + * + * Handles both slash-asterisk and slash-slash comments. + * Also, quoted strings, but no escapes within. + * + * Line is returned in Gbl_CurrentLineBuffer. + * Line number in original file is returned in Gbl_CurrentLineNumber. + * + *****************************************************************************/ + +UINT32 +DtGetNextLine ( + FILE *Handle) +{ + UINT32 State = DT_NORMAL_TEXT; + UINT32 CurrentLineOffset; + UINT32 i; + char c; + + + for (i = 0; i < ASL_LINE_BUFFER_SIZE;) + { + c = (char) getc (Handle); + if (c == EOF) + { + switch (State) + { + case DT_START_QUOTED_STRING: + case DT_SLASH_ASTERISK_COMMENT: + case DT_SLASH_SLASH_COMMENT: + + AcpiOsPrintf ("**** EOF within comment/string %u\n", State); + break; + + default: + break; + } + + return (0); + } + + switch (State) + { + case DT_NORMAL_TEXT: + + /* Normal text, insert char into line buffer */ + + Gbl_CurrentLineBuffer[i] = c; + switch (c) + { + case '/': + State = DT_START_COMMENT; + break; + + case '"': + State = DT_START_QUOTED_STRING; + i++; + break; + + case '\n': + CurrentLineOffset = Gbl_NextLineOffset; + Gbl_NextLineOffset = (UINT32) ftell (Handle); + Gbl_CurrentLineNumber++; + + /* Exit if line is complete. Ignore blank lines */ + + if (i != 0) + { + Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate line */ + return (CurrentLineOffset); + } + break; + + default: + i++; + break; + } + break; + + case DT_START_QUOTED_STRING: + + /* Insert raw chars until end of quoted string */ + + Gbl_CurrentLineBuffer[i] = c; + i++; + + if (c == '"') + { + State = DT_NORMAL_TEXT; + } + break; + + case DT_START_COMMENT: + + /* Open comment if this character is an asterisk or slash */ + + switch (c) + { + case '*': + State = DT_SLASH_ASTERISK_COMMENT; + break; + + case '/': + State = DT_SLASH_SLASH_COMMENT; + break; + + default: /* Not a comment */ + i++; /* Save the preceeding slash */ + Gbl_CurrentLineBuffer[i] = c; + i++; + State = DT_NORMAL_TEXT; + break; + } + break; + + case DT_SLASH_ASTERISK_COMMENT: + + /* Ignore chars until an asterisk-slash is found */ + + switch (c) + { + case '\n': + Gbl_NextLineOffset = (UINT32) ftell (Handle); + Gbl_CurrentLineNumber++; + break; + + case '*': + State = DT_END_COMMENT; + break; + + default: + break; + } + break; + + case DT_SLASH_SLASH_COMMENT: + + /* Ignore chars until end-of-line */ + + if (c == '\n') + { + /* We will exit via the NORMAL_TEXT path */ + + ungetc (c, Handle); + State = DT_NORMAL_TEXT; + } + break; + + case DT_END_COMMENT: + + /* End comment if this char is a slash */ + + switch (c) + { + case '/': + State = DT_NORMAL_TEXT; + break; + + case '\n': + CurrentLineOffset = Gbl_NextLineOffset; + Gbl_NextLineOffset = (UINT32) ftell (Handle); + Gbl_CurrentLineNumber++; + break; + + case '*': + /* Consume all adjacent asterisks */ + break; + + default: + State = DT_SLASH_ASTERISK_COMMENT; + break; + } + break; + + default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state"); + return (0); + } + } + + printf ("ERROR - Input line is too long (max %u)\n", ASL_LINE_BUFFER_SIZE); + return (0); +} + + +/****************************************************************************** + * + * FUNCTION: DtScanFile + * + * PARAMETERS: Handle - Open file handle for the source file + * + * RETURN: Pointer to start of the constructed parse tree. + * + * DESCRIPTION: Scan source file, link all field names and values + * to the global parse tree: Gbl_FieldList + * + *****************************************************************************/ + +DT_FIELD * +DtScanFile ( + FILE *Handle) +{ + ACPI_STATUS Status; + UINT32 Offset; + + + ACPI_FUNCTION_NAME (DtScanFile); + + + /* Get the file size */ + + Gbl_InputByteCount = DtGetFileSize (Handle); + + Gbl_CurrentLineNumber = 0; + Gbl_CurrentLineOffset = 0; + Gbl_NextLineOffset = 0; + + /* Scan line-by-line */ + + while ((Offset = DtGetNextLine (Handle))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s", + Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer)); + + Status = DtParseLine (Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber, Offset); + if (Status == AE_NOT_FOUND) + { + break; + } + } + + return (Gbl_FieldList); +} + + +/* + * Output functions + */ + +/****************************************************************************** + * + * FUNCTION: DtWriteBinary + * + * PARAMETERS: DT_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Write one subtable of a binary ACPI table + * + *****************************************************************************/ + +static void +DtWriteBinary ( + DT_SUBTABLE *Subtable, + void *Context, + void *ReturnValue) +{ + + FlWriteFile (ASL_FILE_AML_OUTPUT, Subtable->Buffer, Subtable->Length); +} + + +/****************************************************************************** + * + * FUNCTION: DtOutputBinary + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: Write entire binary ACPI table (result of compilation) + * + *****************************************************************************/ + +void +DtOutputBinary ( + DT_SUBTABLE *RootTable) +{ + + if (!RootTable) + { + return; + } + + /* Walk the entire parse tree, emitting the binary data */ + + DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); + Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); +} + + +/* + * Listing support + */ + +/****************************************************************************** + * + * FUNCTION: DtDumpBuffer + * + * PARAMETERS: FileID - Where to write buffer data + * Buffer - Buffer to dump + * Offset - Offset in current table + * Length - Buffer Length + * + * RETURN: None + * + * DESCRIPTION: Another copy of DumpBuffer routine (unfortunately). + * + * TBD: merge dump buffer routines + * + *****************************************************************************/ + +static void +DtDumpBuffer ( + UINT32 FileId, + UINT8 *Buffer, + UINT32 Offset, + UINT32 Length) +{ + UINT32 i; + UINT32 j; + UINT8 BufChar; + + + FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ", + Offset, Offset, Length); + + i = 0; + while (i < Length) + { + if (i >= 16) + { + FlPrintFile (FileId, "%23s", ""); + } + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Length) + { + /* Dump fill spaces */ + + FlPrintFile (FileId, " "); + j++; + continue; + } + + FlPrintFile (FileId, "%02X ", Buffer[i+j]); + j++; + } + + FlPrintFile (FileId, " "); + for (j = 0; j < 16; j++) + { + if (i + j >= Length) + { + FlPrintFile (FileId, "\n\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + FlPrintFile (FileId, "%c", BufChar); + } + else + { + FlPrintFile (FileId, "."); + } + } + + /* Done with that line. */ + + FlPrintFile (FileId, "\n"); + i += 16; + } + + FlPrintFile (FileId, "\n\n"); +} + + +/****************************************************************************** + * + * FUNCTION: DtWriteFieldToListing + * + * PARAMETERS: Buffer - Contains the compiled data + * Field - Field node for the input line + * Length - Length of the output data + * + * RETURN: None + * + * DESCRIPTION: Write one field to the listing file (if listing is enabled). + * + *****************************************************************************/ + +void +DtWriteFieldToListing ( + UINT8 *Buffer, + DT_FIELD *Field, + UINT32 Length) +{ + UINT8 FileByte; + + + if (!Gbl_ListingFlag || !Field) + { + return; + } + + /* Dump the original source line */ + + FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input: "); + FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset); + + while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK) + { + FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1); + if (FileByte == '\n') + { + break; + } + } + + /* Dump the line as parsed and represented internally */ + + FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n", + Field->Column-4, Field->Name, Field->Value); + + /* Dump the hex data that will be output for this field */ + + DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length); +} + + +/****************************************************************************** + * + * FUNCTION: DtWriteTableToListing + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Write the entire compiled table to the listing file + * in hex format + * + *****************************************************************************/ + +void +DtWriteTableToListing ( + void) +{ + UINT8 *Buffer; + + + if (!Gbl_ListingFlag) + { + return; + } + + /* Read the entire table from the output file */ + + Buffer = UtLocalCalloc (Gbl_TableLength); + FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength); + + /* Dump the raw table data */ + + AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle); + + AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n", + ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength); + AcpiUtDumpBuffer2 (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY); + + AcpiOsRedirectOutput (stdout); +} diff --git a/sys/contrib/dev/acpica-unix/parser/psscope.c b/sys/contrib/dev/acpica-unix/compiler/dtsubtable.c similarity index 56% copy from sys/contrib/dev/acpica-unix/parser/psscope.c copy to sys/contrib/dev/acpica-unix/compiler/dtsubtable.c index 979dbb1515..9b7ea9bbb1 100644 --- a/sys/contrib/dev/acpica-unix/parser/psscope.c +++ b/sys/contrib/dev/acpica-unix/compiler/dtsubtable.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: psscope - Parser scope stack management routines + * Module Name: dtsubtable.c - handling of subtables within ACPI tables * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,262 +113,288 @@ * *****************************************************************************/ +#define __DTSUBTABLE_C__ -#include "acpi.h" -#include "accommon.h" -#include "acparser.h" +#include "aslcompiler.h" +#include "dtcompiler.h" -#define _COMPONENT ACPI_PARSER - ACPI_MODULE_NAME ("psscope") +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtsubtable") -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiPsGetParentScope + * FUNCTION: DtCreateSubtable * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: Buffer - Input buffer + * Length - Buffer length + * RetSubtable - Returned newly created subtable * - * RETURN: Pointer to an Op object + * RETURN: None * - * DESCRIPTION: Get parent of current op being parsed + * DESCRIPTION: Create a subtable that is not listed with ACPI_DMTABLE_INFO + * For example, FACS has 24 bytes reserved at the end + * and it's not listed at AcpiDmTableInfoFacs * - ******************************************************************************/ + *****************************************************************************/ -ACPI_PARSE_OBJECT * -AcpiPsGetParentScope ( - ACPI_PARSE_STATE *ParserState) +void +DtCreateSubtable ( + UINT8 *Buffer, + UINT32 Length, + DT_SUBTABLE **RetSubtable) { + DT_SUBTABLE *Subtable; - return (ParserState->Scope->ParseScope.Op); -} + Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); -/******************************************************************************* - * - * 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. - * - ******************************************************************************/ + /* Create a new buffer for the subtable data */ -BOOLEAN -AcpiPsHasCompletedScope ( - ACPI_PARSE_STATE *ParserState) -{ + Subtable->Buffer = UtLocalCalloc (Length); + ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); + + Subtable->Length = Length; + Subtable->TotalLength = Length; - return ((BOOLEAN) - ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || - !ParserState->Scope->ParseScope.ArgCount))); + *RetSubtable = Subtable; } -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiPsInitScope + * FUNCTION: DtInsertSubtable * - * PARAMETERS: ParserState - Current parser state object - * Root - the Root Node of this new scope + * PARAMETERS: ParentTable - The Parent of the new subtable + * Subtable - The new subtable to insert * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Allocate and init a new scope object + * DESCRIPTION: Insert the new subtable to the parent table * - ******************************************************************************/ + *****************************************************************************/ -ACPI_STATUS -AcpiPsInitScope ( - ACPI_PARSE_STATE *ParserState, - ACPI_PARSE_OBJECT *RootOp) +void +DtInsertSubtable ( + DT_SUBTABLE *ParentTable, + DT_SUBTABLE *Subtable) { - ACPI_GENERIC_STATE *Scope; + DT_SUBTABLE *ChildTable; - ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); + Subtable->Peer = NULL; + Subtable->Parent = ParentTable; + /* Link the new entry into the child list */ - Scope = AcpiUtCreateGenericState (); - if (!Scope) + if (!ParentTable->Child) { - return_ACPI_STATUS (AE_NO_MEMORY); + ParentTable->Child = Subtable; } + else + { + /* Walk to the end of the child list */ - Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; - Scope->ParseScope.Op = RootOp; - Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; - Scope->ParseScope.ArgEnd = ParserState->AmlEnd; - Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + ChildTable = ParentTable->Child; + while (ChildTable->Peer) + { + ChildTable = ChildTable->Peer; + } - ParserState->Scope = Scope; - ParserState->StartOp = RootOp; + /* Add new subtable at the end of the child list */ - return_ACPI_STATUS (AE_OK); + ChildTable->Peer = Subtable; + } } -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiPsPushScope + * FUNCTION: DtPushSubtable * - * PARAMETERS: ParserState - Current parser state object - * Op - Current op to be pushed - * RemainingArgs - List of args remaining - * ArgCount - Fixed or variable number of args + * PARAMETERS: Subtable - Subtable to push * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Push current op to begin parsing its argument + * DESCRIPTION: Push a subtable onto a subtable stack * - ******************************************************************************/ + *****************************************************************************/ -ACPI_STATUS -AcpiPsPushScope ( - ACPI_PARSE_STATE *ParserState, - ACPI_PARSE_OBJECT *Op, - UINT32 RemainingArgs, - UINT32 ArgCount) +void +DtPushSubtable ( + DT_SUBTABLE *Subtable) { - ACPI_GENERIC_STATE *Scope; - - ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); + Subtable->StackTop = Gbl_SubtableStack; + Gbl_SubtableStack = Subtable; +} - Scope = AcpiUtCreateGenericState (); - if (!Scope) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } +/****************************************************************************** + * + * FUNCTION: DtPopSubtable + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Pop a subtable from a subtable stack. Uses global SubtableStack + * + *****************************************************************************/ - Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; - Scope->ParseScope.Op = Op; - Scope->ParseScope.ArgList = RemainingArgs; - Scope->ParseScope.ArgCount = ArgCount; - Scope->ParseScope.PkgEnd = ParserState->PkgEnd; +void +DtPopSubtable ( + void) +{ + DT_SUBTABLE *Subtable; - /* Push onto scope stack */ - AcpiUtPushGenericState (&ParserState->Scope, Scope); + Subtable = Gbl_SubtableStack; - if (ArgCount == ACPI_VAR_ARGS) + if (Subtable) { - /* Multiple arguments */ - - Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + Gbl_SubtableStack = Subtable->StackTop; } - else - { - /* Single argument */ +} - Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); - } - return_ACPI_STATUS (AE_OK); +/****************************************************************************** + * + * FUNCTION: DtPeekSubtable + * + * PARAMETERS: None + * + * RETURN: The subtable on top of stack + * + * DESCRIPTION: Get the subtable on top of stack + * + *****************************************************************************/ + +DT_SUBTABLE * +DtPeekSubtable ( + void) +{ + + return (Gbl_SubtableStack); } -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiPsPopScope + * FUNCTION: DtGetNextSubtable * - * 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 + * PARAMETERS: ParentTable - Parent table whose children we are + * getting + * ChildTable - Previous child that was found. + * The NEXT child will be returned * - * RETURN: Status + * RETURN: Pointer to the NEXT child or NULL if none is found. * - * DESCRIPTION: Return to parsing a previous op + * DESCRIPTION: Return the next peer subtable within the tree. * - ******************************************************************************/ + *****************************************************************************/ -void -AcpiPsPopScope ( - ACPI_PARSE_STATE *ParserState, - ACPI_PARSE_OBJECT **Op, - UINT32 *ArgList, - UINT32 *ArgCount) +DT_SUBTABLE * +DtGetNextSubtable ( + DT_SUBTABLE *ParentTable, + DT_SUBTABLE *ChildTable) { - ACPI_GENERIC_STATE *Scope = ParserState->Scope; + ACPI_FUNCTION_ENTRY (); - ACPI_FUNCTION_TRACE (PsPopScope); + if (!ChildTable) + { + /* It's really the parent's _scope_ that we want */ + return (ParentTable->Child); + } - /* Only pop the scope if there is in fact a next scope */ + /* Otherwise just return the next peer (NULL if at end-of-list) */ - if (Scope->Common.Next) - { - Scope = AcpiUtPopGenericState (&ParserState->Scope); + return (ChildTable->Peer); +} - /* Return to parsing previous op */ - *Op = Scope->ParseScope.Op; - *ArgList = Scope->ParseScope.ArgList; - *ArgCount = Scope->ParseScope.ArgCount; - ParserState->PkgEnd = Scope->ParseScope.PkgEnd; +/****************************************************************************** + * + * FUNCTION: DtGetParentSubtable + * + * PARAMETERS: Subtable - Current subtable + * + * RETURN: Parent of the given subtable + * + * DESCRIPTION: Get the parent of the given subtable in the tree + * + *****************************************************************************/ - /* All done with this scope state structure */ +DT_SUBTABLE * +DtGetParentSubtable ( + DT_SUBTABLE *Subtable) +{ - AcpiUtDeleteGenericState (Scope); - } - else + if (!Subtable) { - /* Empty parse stack, prepare to fetch next opcode */ - - *Op = NULL; - *ArgList = 0; - *ArgCount = 0; + return (NULL); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Popped Op %p Args %X\n", *Op, *ArgCount)); - return_VOID; + return (Subtable->Parent); } -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiPsCleanupScope + * FUNCTION: DtGetSubtableLength * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: Field - Current field list pointer + * Info - Data table info * - * RETURN: None + * RETURN: Subtable length * - * DESCRIPTION: Destroy available list, remaining stack levels, and return - * root scope + * DESCRIPTION: Get length of bytes needed to compile the subtable * - ******************************************************************************/ + *****************************************************************************/ -void -AcpiPsCleanupScope ( - ACPI_PARSE_STATE *ParserState) +UINT32 +DtGetSubtableLength ( + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info) { - ACPI_GENERIC_STATE *Scope; + UINT32 ByteLength = 0; - ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); + /* Walk entire Info table; Null name terminates */ - - if (!ParserState) + for (; Info->Name; Info++) { - return_VOID; + ByteLength += DtGetFieldLength (Field, Info); } - /* Delete anything on the scope stack */ + return (ByteLength); +} + + +/****************************************************************************** + * + * FUNCTION: DtSetSubtableLength + * + * PARAMETERS: Subtable - Subtable + * + * RETURN: None + * + * DESCRIPTION: Set length of the subtable into its length field + * + *****************************************************************************/ + +void +DtSetSubtableLength ( + DT_SUBTABLE *Subtable) +{ - while (ParserState->Scope) + if (!Subtable->LengthField) { - Scope = AcpiUtPopGenericState (&ParserState->Scope); - AcpiUtDeleteGenericState (Scope); + return; } - return_VOID; + ACPI_MEMCPY (Subtable->LengthField, &Subtable->TotalLength, + Subtable->SizeOfLengthField); } - diff --git a/sys/contrib/dev/acpica-unix/compiler/dttable.c b/sys/contrib/dev/acpica-unix/compiler/dttable.c new file mode 100644 index 0000000000..571c02c682 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dttable.c @@ -0,0 +1,1544 @@ +/****************************************************************************** + * + * Module Name: dttable.c - handling for specific ACPI tables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTTABLE_C__ + +/* Compile all complex data tables */ + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttable") + + +/* TBD: merge these into dmtbinfo.c? */ + +static ACPI_DMTABLE_INFO TableInfoAsfAddress[] = +{ + {ACPI_DMT_BUFFER, 0, "Addresses", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + +static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] = +{ + {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0}, + {ACPI_DMT_EXIT, 0, NULL, 0} +}; + + +/* TBD: move to acmacros.h */ + +#define ACPI_SUB_PTR(t, a, b) \ + ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b))) + + +/* Local prototypes */ + +static ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2); + + +/****************************************************************************** + * + * FUNCTION: DtCompileTwoSubtables + * + * PARAMETERS: List - Current field list pointer + * TableInfo1 - Info table 1 + * TableInfo1 - Info table 2 + * + * RETURN: Status + * + * DESCRIPTION: Compile tables with a header and one or more same subtables. + * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT + * + *****************************************************************************/ + +static ACPI_STATUS +DtCompileTwoSubtables ( + void **List, + ACPI_DMTABLE_INFO *TableInfo1, + ACPI_DMTABLE_INFO *TableInfo2) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + + + Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileFacs + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile FACS. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileFacs ( + DT_FIELD **PFieldList) +{ + DT_SUBTABLE *Subtable; + UINT8 *ReservedBuffer; + ACPI_STATUS Status; + UINT32 ReservedSize; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, + &Gbl_RootTable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Large FACS reserved area at the end of the table */ + + ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); + ReservedBuffer = UtLocalCalloc (ReservedSize); + + DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); + + ACPI_FREE (ReservedBuffer); + DtInsertSubtable (Gbl_RootTable, Subtable); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileRsdp + * + * PARAMETERS: PFieldList - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile RSDP. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileRsdp ( + DT_FIELD **PFieldList) +{ + DT_SUBTABLE *Subtable; + ACPI_TABLE_RSDP *Rsdp; + ACPI_RSDP_EXTENSION *RsdpExtension; + ACPI_STATUS Status; + + + /* Compile the "common" RSDP (ACPI 1.0) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1, + &Gbl_RootTable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer); + DtSetTableChecksum (&Rsdp->Checksum); + + if (Rsdp->Revision > 0) + { + /* Compile the "extended" part of the RSDP as a subtable */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (Gbl_RootTable, Subtable); + + /* Set length and extended checksum for entire RSDP */ + + RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer); + RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length; + DtSetTableChecksum (&RsdpExtension->ExtendedChecksum); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileAsf + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ASF!. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileAsf ( + void **List) +{ + ACPI_ASF_INFO *AsfTable; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_DMTABLE_INFO *DataInfoTable = NULL; + UINT32 DataCount = 0; + ACPI_STATUS Status; + UINT32 i; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + InfoTable = AcpiDmTableInfoAsf0; + break; + + case ACPI_ASF_TYPE_ALERT: + InfoTable = AcpiDmTableInfoAsf1; + break; + + case ACPI_ASF_TYPE_CONTROL: + InfoTable = AcpiDmTableInfoAsf2; + break; + + case ACPI_ASF_TYPE_BOOT: + InfoTable = AcpiDmTableInfoAsf3; + break; + + case ACPI_ASF_TYPE_ADDRESS: + InfoTable = AcpiDmTableInfoAsf4; + break; + + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ + { + case ACPI_ASF_TYPE_INFO: + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ALERT: + DataInfoTable = AcpiDmTableInfoAsf1a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Alerts; + break; + + case ACPI_ASF_TYPE_CONTROL: + DataInfoTable = AcpiDmTableInfoAsf2a; + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Controls; + break; + + case ACPI_ASF_TYPE_BOOT: + DataInfoTable = NULL; + break; + + case ACPI_ASF_TYPE_ADDRESS: + DataInfoTable = TableInfoAsfAddress; + DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, + ACPI_SUB_PTR (UINT8, Subtable->Buffer, + sizeof (ACPI_ASF_HEADER)))->Devices; + break; + + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); + return (AE_ERROR); + } + + if (DataInfoTable) + { + switch (AsfTable->Header.Type & 0x7F) + { + case ACPI_ASF_TYPE_ADDRESS: + + while (DataCount > 0) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + DataCount = DataCount - Subtable->Length; + } + break; + + default: + + for (i = 0; i < DataCount; i++) + { + Status = DtCompileTable (PFieldList, DataInfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + break; + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileCpep + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile CPEP. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCpep ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileDmar + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DMAR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDmar ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_DMAR_HEADER *DmarHeader; + UINT8 *ReservedBuffer; + UINT32 ReservedSize; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* DMAR Reserved area */ + + ReservedSize = (UINT32) sizeof (((ACPI_TABLE_DMAR *) NULL)->Reserved); + ReservedBuffer = UtLocalCalloc (ReservedSize); + + DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); + + ACPI_FREE (ReservedBuffer); + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + /* DMAR Header */ + + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); + + switch (DmarHeader->Type) + { + case ACPI_DMAR_TYPE_HARDWARE_UNIT: + InfoTable = AcpiDmTableInfoDmar0; + break; + case ACPI_DMAR_TYPE_RESERVED_MEMORY: + InfoTable = AcpiDmTableInfoDmar1; + break; + case ACPI_DMAR_TYPE_ATSR: + InfoTable = AcpiDmTableInfoDmar2; + break; + case ACPI_DMAR_HARDWARE_AFFINITY: + InfoTable = AcpiDmTableInfoDmar3; + break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); + return (AE_ERROR); + } + + /* DMAR Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Optional Device Scope subtables */ + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + /* Optional PCI Paths */ + + while (*PFieldList) + { + Status = DtCompileTable (PFieldList, TableInfoDmarPciPath, + &Subtable, FALSE); + if (Status == AE_NOT_FOUND) + { + DtPopSubtable (); + break; + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileEinj + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile EINJ. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileEinj ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileErst + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ERST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileErst ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoErst, AcpiDmTableInfoEinj0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileFadt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile FADT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileFadt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_TABLE_HEADER *Table; + UINT8 Revision; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); + Revision = Table->Revision; + + if (Revision == 2) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + else if (Revision >= 2) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileHest + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile HEST. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileHest ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + UINT16 Type; + UINT32 BankCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + /* Get subtable type */ + + SubtableStart = *PFieldList; + DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); + + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + InfoTable = AcpiDmTableInfoHest0; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + InfoTable = AcpiDmTableInfoHest1; + break; + + case ACPI_HEST_TYPE_IA32_NMI: + InfoTable = AcpiDmTableInfoHest2; + break; + + case ACPI_HEST_TYPE_AER_ROOT_PORT: + InfoTable = AcpiDmTableInfoHest6; + break; + + case ACPI_HEST_TYPE_AER_ENDPOINT: + InfoTable = AcpiDmTableInfoHest7; + break; + + case ACPI_HEST_TYPE_AER_BRIDGE: + InfoTable = AcpiDmTableInfoHest8; + break; + + case ACPI_HEST_TYPE_GENERIC_ERROR: + InfoTable = AcpiDmTableInfoHest9; + break; + + default: + /* Cannot continue on unknown type */ + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional subtable data - IA32 Error Bank(s) + */ + BankCount = 0; + switch (Type) + { + case ACPI_HEST_TYPE_IA32_CHECK: + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, + Subtable->Buffer))->NumHardwareBanks; + break; + + case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, + Subtable->Buffer))->NumHardwareBanks; + break; + + default: + break; + } + + while (BankCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + BankCount--; + } + } + + return AE_OK; +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileIvrs + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile IVRS. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileIvrs ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_IVRS_HEADER *IvrsHeader; + UINT8 EntryType; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer); + + switch (IvrsHeader->Type) + { + case ACPI_IVRS_TYPE_HARDWARE: + InfoTable = AcpiDmTableInfoIvrs0; + break; + + case ACPI_IVRS_TYPE_MEMORY1: + case ACPI_IVRS_TYPE_MEMORY2: + case ACPI_IVRS_TYPE_MEMORY3: + InfoTable = AcpiDmTableInfoIvrs1; + break; + + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE) + { + while (*PFieldList && + !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type")) + { + SubtableStart = *PFieldList; + DtCompileInteger (&EntryType, *PFieldList, 1, 0); + + switch (EntryType) + { + /* 4-byte device entries */ + + case ACPI_IVRS_TYPE_PAD4: + case ACPI_IVRS_TYPE_ALL: + case ACPI_IVRS_TYPE_SELECT: + case ACPI_IVRS_TYPE_START: + case ACPI_IVRS_TYPE_END: + + InfoTable = AcpiDmTableInfoIvrs4; + break; + + /* 8-byte entries, type A */ + + case ACPI_IVRS_TYPE_ALIAS_SELECT: + case ACPI_IVRS_TYPE_ALIAS_START: + + InfoTable = AcpiDmTableInfoIvrs8a; + break; + + /* 8-byte entries, type B */ + + case ACPI_IVRS_TYPE_PAD8: + case ACPI_IVRS_TYPE_EXT_SELECT: + case ACPI_IVRS_TYPE_EXT_START: + + InfoTable = AcpiDmTableInfoIvrs8b; + break; + + /* 8-byte entries, type C */ + + case ACPI_IVRS_TYPE_SPECIAL: + + InfoTable = AcpiDmTableInfoIvrs8c; + break; + + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, + "IVRS Device Entry"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + } + + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMadt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MADT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMadt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *MadtHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (MadtHeader->Type) + { + case ACPI_MADT_TYPE_LOCAL_APIC: + InfoTable = AcpiDmTableInfoMadt0; + break; + case ACPI_MADT_TYPE_IO_APIC: + InfoTable = AcpiDmTableInfoMadt1; + break; + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + InfoTable = AcpiDmTableInfoMadt2; + break; + case ACPI_MADT_TYPE_NMI_SOURCE: + InfoTable = AcpiDmTableInfoMadt3; + break; + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + InfoTable = AcpiDmTableInfoMadt4; + break; + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + InfoTable = AcpiDmTableInfoMadt5; + break; + case ACPI_MADT_TYPE_IO_SAPIC: + InfoTable = AcpiDmTableInfoMadt6; + break; + case ACPI_MADT_TYPE_LOCAL_SAPIC: + InfoTable = AcpiDmTableInfoMadt7; + break; + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: + InfoTable = AcpiDmTableInfoMadt8; + break; + case ACPI_MADT_TYPE_LOCAL_X2APIC: + InfoTable = AcpiDmTableInfoMadt9; + break; + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + InfoTable = AcpiDmTableInfoMadt10; + break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMcfg + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MCFG. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMcfg ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileMsct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MSCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMsct ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileRsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile RSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileRsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT32 Address; + + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSlit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SLIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSlit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *FieldList; + UINT32 Localities; + UINT8 *LocalityBuffer; + UINT32 RemainingData; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); + LocalityBuffer = UtLocalCalloc (Localities); + + FieldList = *PFieldList; + while (FieldList) + { + /* Handle multiple-line buffer */ + + RemainingData = Localities; + while (RemainingData && FieldList) + { + RemainingData = DtCompileBuffer ( + LocalityBuffer + (Localities - RemainingData), + FieldList->Value, FieldList, RemainingData); + FieldList = FieldList->Next; + } + + DtCreateSubtable (LocalityBuffer, Localities, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + } + + ACPI_FREE (LocalityBuffer); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileSrat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile SRAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileSrat ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *SratHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (SratHeader->Type) + { + case ACPI_SRAT_TYPE_CPU_AFFINITY: + InfoTable = AcpiDmTableInfoSrat0; + break; + case ACPI_SRAT_TYPE_MEMORY_AFFINITY: + InfoTable = AcpiDmTableInfoSrat1; + break; + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + InfoTable = AcpiDmTableInfoSrat2; + break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetGenericTableInfo + * + * PARAMETERS: Name - Generic type name + * + * RETURN: Info entry + * + * DESCRIPTION: Obtain table info for a generic name entry + * + *****************************************************************************/ + +ACPI_DMTABLE_INFO * +DtGetGenericTableInfo ( + char *Name) +{ + ACPI_DMTABLE_INFO *Info; + UINT32 i; + + + if (!Name) + { + return (NULL); + } + + /* Search info table for name match */ + + for (i = 0; ; i++) + { + Info = AcpiDmTableInfoGeneric[i]; + if (Info->Opcode == ACPI_DMT_EXIT) + { + Info = NULL; + break; + } + + if (!ACPI_STRCMP (Name, Info->Name)) + { + break; + } + } + + return (Info); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileUefi + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile UEFI. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileUefi ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_DMTABLE_INFO *Info; + UINT16 *DataOffset; + + + /* Compile the predefined portion of the UEFI table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DataOffset = (UINT16 *) (Subtable->Buffer + 16); + *DataOffset = sizeof (ACPI_TABLE_UEFI); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Compile the "generic" portion of the UEFI table. This + * part of the table is not predefined and any of the generic + * operators may be used. + */ + + /* Find any and all labels in the entire generic portion */ + + DtDetectAllLabels (*PFieldList); + + /* Now we can actually compile the parse tree */ + + while (*PFieldList) + { + Info = DtGetGenericTableInfo ((*PFieldList)->Name); + if (!Info) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + + *PFieldList = (*PFieldList)->Next; + continue; + } + + Status = DtCompileTable (PFieldList, Info, + &Subtable, TRUE); + if (ACPI_SUCCESS (Status)) + { + DtInsertSubtable (ParentTable, Subtable); + } + else + { + *PFieldList = (*PFieldList)->Next; + + if (Status == AE_NOT_FOUND) + { + sprintf (MsgBuffer, "Generic data type \"%s\" not found", + (*PFieldList)->Name); + DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, + (*PFieldList), MsgBuffer); + } + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileWdat + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile WDAT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileWdat ( + void **List) +{ + ACPI_STATUS Status; + + + Status = DtCompileTwoSubtables (List, + AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: DtCompileXsdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile XSDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileXsdt ( + void **List) +{ + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD *FieldList = *(DT_FIELD **) List; + UINT64 Address; + + ParentTable = DtPeekSubtable (); + + while (FieldList) + { + DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); + + DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); + DtInsertSubtable (ParentTable, Subtable); + FieldList = FieldList->Next; + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/events/evevent.c b/sys/contrib/dev/acpica-unix/compiler/dttemplate.c similarity index 52% copy from sys/contrib/dev/acpica-unix/events/evevent.c copy to sys/contrib/dev/acpica-unix/compiler/dttemplate.c index 16f40271fc..a7b1ae8629 100644 --- a/sys/contrib/dev/acpica-unix/events/evevent.c +++ b/sys/contrib/dev/acpica-unix/compiler/dttemplate.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: evevent - Fixed Event handling and dispatch + * Module Name: dttemplate - ACPI table template generation * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,202 +113,182 @@ * *****************************************************************************/ -#include "acpi.h" -#include "accommon.h" -#include "acevents.h" +#include "aslcompiler.h" +#include "acapps.h" +#include "dtcompiler.h" +#include "dttemplate.h" /* Contains the hex ACPI table templates */ + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dttemplate") -#define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evevent") /* Local prototypes */ +static BOOLEAN +AcpiUtIsSpecialTable ( + char *Signature); + static ACPI_STATUS -AcpiEvFixedEventInitialize ( - void); +DtCreateOneTemplate ( + char *Signature, + ACPI_DMTABLE_DATA *TableData); -static UINT32 -AcpiEvFixedEventDispatch ( - UINT32 Event); +static ACPI_STATUS +DtCreateAllTemplates ( + void); /******************************************************************************* * - * FUNCTION: AcpiEvInitializeEvents + * FUNCTION: AcpiUtIsSpecialTable * - * PARAMETERS: None + * PARAMETERS: Signature - ACPI table signature * - * RETURN: Status + * RETURN: TRUE if signature is a special ACPI table * - * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) + * DESCRIPTION: Check for valid ACPI tables that are not in the main ACPI + * table data structure (AcpiDmTableData). * ******************************************************************************/ -ACPI_STATUS -AcpiEvInitializeEvents ( - void) +static BOOLEAN +AcpiUtIsSpecialTable ( + char *Signature) { - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvInitializeEvents); - - - /* - * Initialize the Fixed and General Purpose Events. This is done prior to - * enabling SCIs to prevent interrupts from occurring before the handlers - * are installed. - */ - Status = AcpiEvFixedEventInitialize (); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to initialize fixed events")); - return_ACPI_STATUS (Status); - } - Status = AcpiEvGpeInitialize (); - if (ACPI_FAILURE (Status)) + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) || + ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS) || + ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME)) { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to initialize general purpose events")); - return_ACPI_STATUS (Status); + return (TRUE); } - return_ACPI_STATUS (Status); + return (FALSE); } /******************************************************************************* * - * FUNCTION: AcpiEvInstallFadtGpes + * FUNCTION: DtCreateTemplates * - * PARAMETERS: None + * PARAMETERS: Signature - ACPI table signature * * RETURN: Status * - * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks - * (0 and 1). This causes the _PRW methods to be run, so the HW - * must be fully initialized at this point, including global lock - * support. + * DESCRIPTION: Create one or more template files. * ******************************************************************************/ ACPI_STATUS -AcpiEvInstallFadtGpes ( - void) +DtCreateTemplates ( + char *Signature) { + ACPI_DMTABLE_DATA *TableData; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (EvInstallFadtGpes); - + AslInitializeGlobals (); + AcpiUtStrupr (Signature); - /* Namespace must be locked */ + /* Create all known templates if requested */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) + if (!ACPI_STRNCMP (Signature, "ALL", 3)) { + Status = DtCreateAllTemplates (); return (Status); } - /* FADT GPE Block 0 */ - - (void) AcpiEvInitializeGpeBlock ( - AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[0]); - - /* FADT GPE Block 1 */ - - (void) AcpiEvInitializeGpeBlock ( - AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[1]); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvInstallXruptHandlers - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvInstallXruptHandlers ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvInstallXruptHandlers); - - - /* Install the SCI handler */ + /* + * Validate signature and get the template data: + * 1) Signature must be 4 characters + * 2) Signature must be a recognized ACPI table + * 3) There must be a template associated with the signature + */ + if (strlen (Signature) != ACPI_NAME_SIZE) + { + fprintf (stderr, "%s, Invalid ACPI table signature\n", Signature); + return (AE_ERROR); + } - Status = AcpiEvInstallSciHandler (); - if (ACPI_FAILURE (Status)) + /* + * Some slack for the two strange tables whose name is different than + * their signatures: MADT->APIC and FADT->FACP. + */ + if (!strcmp (Signature, "MADT")) { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to install System Control Interrupt handler")); - return_ACPI_STATUS (Status); + Signature = "APIC"; + } + else if (!strcmp (Signature, "FADT")) + { + Signature = "FACP"; } - /* Install the handler for the Global Lock */ + TableData = AcpiDmGetTableData (Signature); + if (TableData) + { + if (!TableData->Template) + { + fprintf (stderr, "%4.4s, No template available\n", Signature); + return (AE_ERROR); + } + } + else if (!AcpiUtIsSpecialTable (Signature)) + { + fprintf (stderr, + "%4.4s, Unrecognized ACPI table signature\n", Signature); + return (AE_ERROR); + } - Status = AcpiEvInitGlobalLockHandler (); + Status = AdInitialize (); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to initialize Global Lock handler")); - return_ACPI_STATUS (Status); + return (Status); } - AcpiGbl_EventsInitialized = TRUE; - return_ACPI_STATUS (Status); + Status = DtCreateOneTemplate (Signature, TableData); + return (Status); } /******************************************************************************* * - * FUNCTION: AcpiEvFixedEventInitialize + * FUNCTION: DtCreateAllTemplates * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Install the fixed event handlers and disable all fixed events. + * DESCRIPTION: Create all currently defined template files * ******************************************************************************/ static ACPI_STATUS -AcpiEvFixedEventInitialize ( +DtCreateAllTemplates ( void) { - UINT32 i; + ACPI_DMTABLE_DATA *TableData; ACPI_STATUS Status; - /* - * Initialize the structure that keeps track of fixed event handlers and - * enable the fixed events. - */ - for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) { - AcpiGbl_FixedEventHandlers[i].Handler = NULL; - AcpiGbl_FixedEventHandlers[i].Context = NULL; + return (Status); + } + + fprintf (stderr, "Creating all supported Template files\n"); - /* Disable the fixed event */ + /* Walk entire ACPI table data structure */ - if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) + for (TableData = AcpiDmTableData; TableData->Signature; TableData++) + { + /* If table has a template, create the template file */ + + if (TableData->Template) { - Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[i].EnableRegisterId, - ACPI_DISABLE_EVENT); + Status = DtCreateOneTemplate (TableData->Signature, + TableData); if (ACPI_FAILURE (Status)) { return (Status); @@ -316,115 +296,150 @@ AcpiEvFixedEventInitialize ( } } + /* + * Create the "special ACPI tables: + * 1) DSDT/SSDT are AML tables, not data tables + * 2) FACS and RSDP have non-standard headers + */ + Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiEvFixedEventDetect + * FUNCTION: DtCreateOneTemplate * - * PARAMETERS: None + * PARAMETERS: Signature - ACPI signature, NULL terminated. + * TableData - Entry in ACPI table data structure. + * NULL if a special ACPI table. * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * RETURN: Status * - * DESCRIPTION: Checks the PM status register for active fixed events + * DESCRIPTION: Create one template source file for the requested ACPI table. * ******************************************************************************/ -UINT32 -AcpiEvFixedEventDetect ( - void) +static ACPI_STATUS +DtCreateOneTemplate ( + char *Signature, + ACPI_DMTABLE_DATA *TableData) { - UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; - UINT32 FixedStatus; - UINT32 FixedEnable; - UINT32 i; - - - ACPI_FUNCTION_NAME (EvFixedEventDetect); - + char *DisasmFilename; + FILE *File; + ACPI_STATUS Status = AE_OK; - /* - * Read the fixed feature status and enable registers, as all the cases - * depend on their values. Ignore errors here. - */ - (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); - (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); - ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Fixed Event Block: Enable %08X Status %08X\n", - FixedEnable, FixedStatus)); + /* New file will have a .asl suffix */ - /* - * Check for all possible Fixed Events and dispatch those that are active - */ - for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + DisasmFilename = FlGenerateFilename ( + Signature, FILE_SUFFIX_ASL_CODE); + if (!DisasmFilename) { - /* Both the status and enable bits must be on for this event */ + fprintf (stderr, "Could not generate output filename\n"); + return (AE_ERROR); + } - if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && - (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) - { - /* Found an active (signalled) event */ + /* Probably should prompt to overwrite the file */ - AcpiFixedEventCount[i]++; - IntStatus |= AcpiEvFixedEventDispatch (i); - } + AcpiUtStrlwr (DisasmFilename); + File = fopen (DisasmFilename, "w+"); + if (!File) + { + fprintf (stderr, "Could not open output file %s\n", DisasmFilename); + return (AE_ERROR); } - return (IntStatus); -} + /* Emit the common file header */ + AcpiOsRedirectOutput (File); -/******************************************************************************* - * - * FUNCTION: AcpiEvFixedEventDispatch - * - * PARAMETERS: Event - Event type - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Clears the status bit for the requested event, calls the - * handler that previously registered for the event. - * - ******************************************************************************/ - -static UINT32 -AcpiEvFixedEventDispatch ( - UINT32 Event) -{ + AcpiOsPrintf ("/*\n"); + AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * ")); - ACPI_FUNCTION_ENTRY (); + AcpiOsPrintf (" * Template for [%4.4s] ACPI Table\n", + Signature); + /* Dump the actual ACPI table */ - /* Clear the status bit */ + if (TableData) + { + /* Normal case, tables that appear in AcpiDmTableData */ - (void) AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - ACPI_CLEAR_STATUS); + if (Gbl_VerboseTemplates) + { + AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]" + " FieldName : HexFieldValue\n */\n\n"); + } + else + { + AcpiOsPrintf (" * Format: [ByteLength]" + " FieldName : HexFieldValue\n */\n\n"); + } - /* - * 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) + AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, + TableData->Template)); + } + else { - (void) AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_DISABLE_EVENT); - - ACPI_ERROR ((AE_INFO, - "No installed handler for fixed event [%08X]", - Event)); + /* Special ACPI tables - DSDT, SSDT, FACS, RSDP */ - return (ACPI_INTERRUPT_NOT_HANDLED); + AcpiOsPrintf (" */\n\n"); + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) + { + fwrite (TemplateDsdt, sizeof (TemplateDsdt) -1, 1, File); + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT)) + { + fwrite (TemplateSsdt, sizeof (TemplateSsdt) -1, 1, File); + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) + { + AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, + TemplateFacs)); + } + else if (ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME)) + { + AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, + TemplateRsdp)); + } + else + { + fprintf (stderr, + "%4.4s, Unrecognized ACPI table signature\n", Signature); + return (AE_ERROR); + } } - /* Invoke the Fixed Event handler */ + fprintf (stderr, + "Created ACPI table template for [%4.4s], written to \"%s\"\n", + Signature, DisasmFilename); - return ((AcpiGbl_FixedEventHandlers[Event].Handler)( - AcpiGbl_FixedEventHandlers[Event].Context)); + fclose (File); + AcpiOsRedirectOutput (stdout); + ACPI_FREE (DisasmFilename); + return (Status); } - - diff --git a/sys/contrib/dev/acpica-unix/compiler/dttemplate.h b/sys/contrib/dev/acpica-unix/compiler/dttemplate.h new file mode 100644 index 0000000000..a6608a3f00 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dttemplate.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Module Name: dttemplate.h - ACPI table template definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 __DTTEMPLATE_H +#define __DTTEMPLATE_H + + +/* Special templates for DSDT and SSDT (AML byte-code tables) */ + +const char TemplateDsdt[] = + "DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" + "{\n" + " Method (MAIN, 0, NotSerialized)\n" + " {\n" + " Return (Zero)\n" + " }\n" + "}\n\n"; + +const char TemplateSsdt[] = + "DefinitionBlock (\"ssdt.aml\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" + "{\n" + " Method (MAIN, 0, NotSerialized)\n" + " {\n" + " Return (Zero)\n" + " }\n" + "}\n\n"; + + +/* Templates for ACPI data tables */ + +const unsigned char TemplateAsf[] = +{ + 0x41,0x53,0x46,0x21,0x72,0x00,0x00,0x00, /* 00000000 "ASF!r..." */ + 0x10,0x0B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x10,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x14,0x00, /* 00000030 "........" */ + 0x00,0x00,0x01,0x0C,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x02,0x00,0x0C,0x00,0x01,0x04,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x03,0x00,0x17,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x84,0x00,0x07,0x00,0x00, /* 00000068 "........" */ + 0x01,0x00 /* 00000070 ".." */ +}; + +const unsigned char TemplateBert[] = +{ + 0x42,0x45,0x52,0x54,0x30,0x00,0x00,0x00, /* 00000000 "BERT0..." */ + 0x01,0x15,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000028 "........" */ +}; + +const unsigned char TemplateBoot[] = +{ + 0x42,0x4F,0x4F,0x54,0x28,0x00,0x00,0x00, /* 00000000 "BOOT(..." */ + 0x01,0x0D,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x04,0x06,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00 /* 00000020 "(.. ...." */ +}; + +const unsigned char TemplateCpep[] = +{ + 0x43,0x50,0x45,0x50,0x34,0x00,0x00,0x00, /* 00000000 "CPEP4..." */ + 0x01,0x0F,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00 /* 00000030 "...." */ +}; + +const unsigned char TemplateDbgp[] = +{ + 0x44,0x42,0x47,0x50,0x34,0x00,0x00,0x00, /* 00000000 "DBGP4..." */ + 0x01,0x1A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00 /* 00000030 "...." */ +}; + +const unsigned char TemplateDmar[] = +{ + 0x44,0x4D,0x41,0x52,0x8C,0x00,0x00,0x00, /* 00000000 "DMAR...." */ + 0x01,0x15,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x2F,0x01,0x00,0x00, /* 00000020 "(.. /..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x18,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x02,0xFD,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x03,0x08,0x00,0x00,0x08,0xF0,0x1F,0x07, /* 00000040 "........" */ + 0x01,0x00,0x20,0x00,0x00,0x00,0x00,0x00, /* 00000048 ".. ....." */ + 0x00,0x10,0xC2,0x78,0x00,0x00,0x00,0x00, /* 00000050 "...x...." */ + 0xFF,0x3F,0xC2,0x78,0x00,0x00,0x00,0x00, /* 00000058 ".?.x...." */ + 0x01,0x08,0x00,0x00,0x00,0x00,0x1D,0x00, /* 00000060 "........" */ + 0x02,0x00,0x10,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x02,0x08,0x00,0x00,0x00,0x00,0x01,0x00, /* 00000070 "........" */ + 0x03,0x00,0x14,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x02,0xFD,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00 /* 00000088 "...." */ +}; + +const unsigned char TemplateEcdt[] = +{ + 0x45,0x43,0x44,0x54,0x42,0x00,0x00,0x00, /* 00000000 "ECDTB..." */ + 0x01,0x2D,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".-INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x01,0x08,0x00,0x00, /* 00000020 "(.. ...." */ + 0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "f......." */ + 0x01,0x08,0x00,0x00,0x62,0x00,0x00,0x00, /* 00000030 "....b..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x09,0x00 /* 00000040 ".." */ +}; + +const unsigned char TemplateEinj[] = +{ + 0x45,0x49,0x4E,0x4A,0x30,0x01,0x00,0x00, /* 00000000 "EINJ0..." */ + 0x01,0x09,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x30,0x00,0x00,0x00, /* 00000020 "(.. 0..." */ + 0x00,0x00,0x00,0x00,0x0A,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000030 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000048 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000050 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000068 "........" */ + 0x02,0x02,0x01,0x00,0x00,0x40,0x00,0x04, /* 00000070 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000088 "........" */ + 0x03,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000090 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000A8 "........" */ + 0x04,0x03,0x01,0x00,0x00,0x40,0x00,0x04, /* 000000B0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000C8 "........" */ + 0x05,0x03,0x01,0x00,0x01,0x10,0x00,0x02, /* 000000D0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000E8 "........" */ + 0x06,0x01,0x00,0x00,0x00,0x40,0x00,0x04, /* 000000F0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000108 "........" */ + 0x07,0x00,0x01,0x00,0x00,0x40,0x00,0x04, /* 00000110 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF /* 00000128 "........" */ +}; + +const unsigned char TemplateErst[] = +{ + 0x45,0x52,0x53,0x54,0x30,0x02,0x00,0x00, /* 00000000 "ERST0..." */ + 0x01,0xAB,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x30,0x00,0x00,0x00, /* 00000020 "(.. 0..." */ + 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x03,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000030 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000048 "........" */ + 0x01,0x03,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000050 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000068 "........" */ + 0x02,0x03,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000070 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000088 "........" */ + 0x03,0x04,0x01,0x00,0x00,0x40,0x00,0x04, /* 00000090 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000A8 "........" */ + 0x04,0x02,0x00,0x00,0x00,0x40,0x00,0x04, /* 000000B0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000C8 "........" */ + 0x05,0x03,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000D0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000000E8 "........" */ + 0x06,0x01,0x00,0x00,0x00,0x40,0x00,0x04, /* 000000F0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000108 "........" */ + 0x07,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000110 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000128 "........" */ + 0x08,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000130 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000140 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000148 "........" */ + 0x09,0x02,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000150 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000158 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000160 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000168 "........" */ + 0x0A,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000170 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000178 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000180 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000188 "........" */ + 0x0B,0x03,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000190 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000198 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001A0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000001A8 "........" */ + 0x0C,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 000001B0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001B8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001C0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000001C8 "........" */ + 0x0D,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 000001D0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001D8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001E0 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 000001E8 "........" */ + 0x0E,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 000001F0 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001F8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000200 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000208 "........" */ + 0x0F,0x00,0x00,0x00,0x00,0x40,0x00,0x04, /* 00000210 ".....@.." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000218 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000220 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF /* 00000228 "........" */ +}; + +const unsigned char TemplateFacs[] = +{ + 0x46,0x41,0x43,0x53,0x40,0x00,0x00,0x00, /* 00000000 "FACS@..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000008 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000010 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000018 "........" */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000020 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000038 "........" */ +}; + +const unsigned char TemplateFadt[] = +{ + 0x46,0x41,0x43,0x50,0xF4,0x00,0x00,0x00, /* 00000000 "FACP...." */ + 0x04,0x4E,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".NINTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x04,0x02,0x01,0x04,0x08,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 000000A8 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00, /* 000000C0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ + 0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00, /* 000000D0 ". ......" */ + 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x01, /* 000000D8 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ + 0x00,0x00,0x00,0x00 /* 000000F0 "...." */ +}; + +const unsigned char TemplateHest[] = +{ + 0x48,0x45,0x53,0x54,0xD4,0x01,0x00,0x00, /* 00000000 "HEST...." */ + 0x01,0x20,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ". INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x04,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, /* 00000028 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x01, /* 00000088 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000D0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ + 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01, /* 000000F0 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000F8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000120 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000128 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000140 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000148 "........" */ + 0x00,0x00,0x00,0x00,0x09,0x00,0x02,0x00, /* 00000150 "........" */ + 0xFF,0xFF,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000158 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00, /* 00000160 "........" */ + 0x00,0x40,0x00,0x04,0x00,0x00,0x00,0x00, /* 00000168 ".@......" */ + 0x00,0x00,0x00,0x00,0x03,0x1C,0x00,0x00, /* 00000170 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000178 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000180 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000188 "........" */ + 0x00,0x10,0x00,0x00,0x09,0x00,0x03,0x00, /* 00000190 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000198 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00, /* 000001A0 "........" */ + 0x00,0x40,0x00,0x04,0x00,0x00,0x00,0x00, /* 000001A8 ".@......" */ + 0x00,0x00,0x00,0x00,0x04,0x1C,0x00,0x00, /* 000001B0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001B8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001C0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000001C8 "........" */ + 0x00,0x10,0x00,0x00 /* 000001D0 "...." */ +}; + +const unsigned char TemplateHpet[] = +{ + 0x48,0x50,0x45,0x54,0x38,0x00,0x00,0x00, /* 00000000 "HPET8..." */ + 0x01,0x09,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000030 "........" */ +}; + +const unsigned char TemplateIvrs[] = +{ + 0x49,0x56,0x52,0x53,0xBC,0x00,0x00,0x00, /* 00000000 "IVRS...." */ + 0x01,0x87,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x10,0x14,0x34,0x00,0x00,0x00,0x00,0x00, /* 00000030 "..4....." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00, /* 00000048 "....@..." */ + 0x00,0x00,0x00,0x00,0x42,0x00,0x00,0x00, /* 00000050 "....B..." */ + 0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00, /* 00000058 "....H..." */ + 0x00,0x00,0x00,0x00,0x20,0x08,0x20,0x00, /* 00000060 ".... . ." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x21,0x04,0x20,0x00, /* 00000080 "....!. ." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x10,0x14,0x18,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x00,0x00,0x00,0x00 /* 000000B8 "...." */ +}; + +const unsigned char TemplateMadt[] = +{ + 0x41,0x50,0x49,0x43,0xB6,0x00,0x00,0x00, /* 00000000 "APIC...." */ + 0x01,0x45,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".EINTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */ + 0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */ + 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */ + 0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ + 0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00 /* 000000B0 "......" */ +}; + +const unsigned char TemplateMcfg[] = +{ + 0x4D,0x43,0x46,0x47,0x3C,0x00,0x00,0x00, /* 00000000 "MCFG<..." */ + 0x01,0x19,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00 /* 00000038 "...." */ +}; + +const unsigned char TemplateMchi[] = +{ + 0x4D,0x43,0x48,0x49,0x45,0x00,0x00,0x00, /* 00000000 "MCHIE..." */ + 0x01,0xE4,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x15,0x07,0x00,0x02,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x02,0x08,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00 /* 00000040 "....." */ +}; + +const unsigned char TemplateMsct[] = +{ + 0x4D,0x53,0x43,0x54,0x90,0x00,0x00,0x00, /* 00000000 "MSCT...." */ + 0x01,0xB7,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x38,0x00,0x00,0x00, /* 00000020 "(.. 8..." */ + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00, /* 00000030 "........" */ + 0x01,0x16,0x00,0x00,0x00,0x00,0x03,0x00, /* 00000038 "........" */ + 0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x40,0x00,0x00,0x00,0x01,0x16, /* 00000048 "..@....." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x16,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x01,0x16,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000088 "........" */ +}; + +const unsigned char TemplateRsdp[] = +{ + 0x52,0x53,0x44,0x20,0x50,0x54,0x52,0x20, /* 00000000 "RSD PTR " */ + 0x43,0x49,0x4E,0x54,0x45,0x4C,0x20,0x02, /* 00000008 "CINTEL ." */ + 0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00, /* 00000010 "....$..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000018 "........" */ + 0xDC,0x00,0x00,0x00 /* 00000020 "...." */ +}; + +const unsigned char TemplateRsdt[] = +{ + 0x52,0x53,0x44,0x54,0x44,0x00,0x00,0x00, /* 00000000 "RSDTD..." */ + 0x01,0xB1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x10,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x20,0x00,0x00,0x00,0x30,0x00,0x00,0x00, /* 00000028 " ...0..." */ + 0x40,0x00,0x00,0x00,0x50,0x00,0x00,0x00, /* 00000030 "@...P..." */ + 0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00, /* 00000038 "`...p..." */ + 0x80,0x00,0x00,0x00 /* 00000040 "...." */ +}; + +const unsigned char TemplateSbst[] = +{ + 0x53,0x42,0x53,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SBST0..." */ + 0x01,0x06,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000028 "........" */ +}; + +const unsigned char TemplateSlit[] = +{ + 0x53,0x4C,0x49,0x54,0x3C,0x00,0x00,0x00, /* 00000000 "SLIT<..." */ + 0x01,0x1B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x04,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x0A,0x0F,0x0F,0x0F, /* 00000028 "........" */ + 0x0F,0x0A,0x0F,0x0F,0x0F,0x0F,0x0A,0x0F, /* 00000030 "........" */ + 0x0F,0x0F,0x0F,0x0A /* 00000038 "...." */ +}; + +const unsigned char TemplateSpcr[] = +{ + 0x53,0x50,0x43,0x52,0x50,0x00,0x00,0x00, /* 00000000 "SPCRP..." */ + 0x01,0xE3,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000048 "........" */ +}; + +const unsigned char TemplateSpmi[] = +{ + 0x53,0x50,0x4D,0x49,0x41,0x00,0x00,0x00, /* 00000000 "SPMIA..." */ + 0x04,0xED,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00 /* 00000040 "." */ +}; + +const unsigned char TemplateSrat[] = +{ + 0x53,0x52,0x41,0x54,0x80,0x00,0x00,0x00, /* 00000000 "SRAT...." */ + 0x03,0x5A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".ZINTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x01,0x28,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 ".(......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0xFC,0x09,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000078 "........" */ +}; + +const unsigned char TemplateTcpa[] = +{ + 0x54,0x43,0x50,0x41,0x32,0x00,0x00,0x00, /* 00000000 "TCPA2..." */ + 0x01,0x67,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".gINTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x80,0x31,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 ".1..INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00 /* 00000030 ".." */ +}; + +const unsigned char TemplateUefi[] = +{ + 0x55,0x45,0x46,0x49,0x36,0x00,0x00,0x00, /* 00000000 "UEFI6..." */ + 0x01,0x9B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x01,0x02,0x03, /* 00000020 "(.. ...." */ + 0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B, /* 00000028 "........" */ + 0x0C,0x0D,0x0E,0x0F,0x00,0x00 /* 00000030 "......" */ +}; + +const unsigned char TemplateWaet[] = +{ + 0x57,0x41,0x45,0x54,0x28,0x00,0x00,0x00, /* 00000000 "WAET(..." */ + 0x01,0x19,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00 /* 00000020 "(.. ...." */ +}; + +const unsigned char TemplateWdat[] = +{ + 0x57,0x44,0x41,0x54,0x5C,0x00,0x00,0x00, /* 00000000 "WDAT\..." */ + 0x01,0xE3,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x20,0x00,0x00,0x00, /* 00000020 "(.. ..." */ + 0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00, /* 00000028 "........" */ + 0x58,0x02,0x00,0x00,0xFF,0x03,0x00,0x00, /* 00000030 "X......." */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x0E,0x00,0x00,0x00,0x01,0x02,0x00,0x00, /* 00000040 "........" */ + 0x01,0x10,0x00,0x02,0x60,0x04,0x00,0x00, /* 00000048 "....`..." */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000050 "........" */ + 0x01,0x00,0x00,0x00 /* 00000058 "...." */ +}; + +const unsigned char TemplateWddt[] = +{ + 0x57,0x44,0x44,0x54,0x40,0x00,0x00,0x00, /* 00000000 "WDDT@..." */ + 0x01,0x00,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x01,0xFF,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000038 "........" */ +}; + +const unsigned char TemplateWdrt[] = +{ + 0x57,0x44,0x52,0x54,0x47,0x00,0x00,0x00, /* 00000000 "WDRTG..." */ + 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x00,0x20,0x00,0x00, /* 00000020 "(.. . .." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ". ......" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0x00 /* 00000040 "......." */ +}; + +const unsigned char TemplateXsdt[] = +{ + 0x58,0x53,0x44,0x54,0x64,0x00,0x00,0x00, /* 00000000 "XSDTd..." */ + 0x01,0x8B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x28,0x05,0x10,0x20,0x10,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, /* 00000028 ".... ..." */ + 0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00, /* 00000030 "....0..." */ + 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00, /* 00000038 "....@..." */ + 0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00, /* 00000040 "....P..." */ + 0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000048 "....`..." */ + 0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00, /* 00000050 "....p..." */ + 0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00 /* 00000060 "...." */ +}; + +#endif diff --git a/sys/contrib/dev/acpica-unix/compiler/dtutils.c b/sys/contrib/dev/acpica-unix/compiler/dtutils.c new file mode 100644 index 0000000000..0048b31ec3 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/compiler/dtutils.c @@ -0,0 +1,937 @@ +/****************************************************************************** + * + * Module Name: dtutils.c - Utility routines for the data table compiler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DTUTILS_C__ + +#include "aslcompiler.h" +#include "dtcompiler.h" +#include "actables.h" + +#define _COMPONENT DT_COMPILER + ACPI_MODULE_NAME ("dtutils") + +/* Local prototypes */ + +static void +DtSum ( + DT_SUBTABLE *Subtable, + void *Context, + void *ReturnValue); + + +/****************************************************************************** + * + * FUNCTION: DtError + * + * PARAMETERS: Level - Seriousness (Warning/error, etc.) + * MessageId - Index into global message buffer + * Op - Parse node where error happened + * ExtraMessage - additional error message + * + * RETURN: None + * + * DESCRIPTION: Common error interface for data table compiler + * + *****************************************************************************/ + +void +DtError ( + UINT8 Level, + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage) +{ + + switch (Level) + { + case ASL_WARNING2: + case ASL_WARNING3: + if (Gbl_WarningLevel < Level) + { + return; + } + break; + + default: + break; + } + + if (FieldObject) + { + AslCommonError (Level, MessageId, + FieldObject->Line, + FieldObject->Line, + FieldObject->ByteOffset, + FieldObject->Column, + Gbl_Files[ASL_FILE_INPUT].Filename, ExtraMessage); + } + else + { + AslCommonError (Level, MessageId, 0, + 0, 0, 0, 0, ExtraMessage); + } +} + + +/****************************************************************************** + * + * FUNCTION: DtNameError + * + * PARAMETERS: Level - Seriousness (Warning/error, etc.) + * MessageId - Index into global message buffer + * Op - Parse node where error happened + * ExtraMessage - additional error message + * + * RETURN: None + * + * DESCRIPTION: Error interface for named objects + * + *****************************************************************************/ + +void +DtNameError ( + UINT8 Level, + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage) +{ + + switch (Level) + { + case ASL_WARNING2: + case ASL_WARNING3: + if (Gbl_WarningLevel < Level) + { + return; + } + break; + + default: + break; + } + + if (FieldObject) + { + AslCommonError (Level, MessageId, + FieldObject->Line, + FieldObject->Line, + FieldObject->ByteOffset, + FieldObject->NameColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, ExtraMessage); + } + else + { + AslCommonError (Level, MessageId, 0, + 0, 0, 0, 0, ExtraMessage); + } +} + + +/******************************************************************************* + * + * FUNCTION: DtFatal + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump the error log and abort the compiler. Used for serious + * compile or I/O errors + * + ******************************************************************************/ + +void +DtFatal ( + UINT8 MessageId, + DT_FIELD *FieldObject, + char *ExtraMessage) +{ + + DtError (ASL_ERROR, MessageId, FieldObject, ExtraMessage); + + CmCleanupAndExit (); + exit (1); +} + + +/****************************************************************************** + * + * FUNCTION: DtStrtoul64 + * + * PARAMETERS: String - Null terminated string + * ReturnInteger - Where the converted integer is returned + * + * RETURN: Status + * + * DESCRIPTION: Simple conversion of a string hex integer constant to unsigned + * value. Assumes no leading "0x" for the constant. + * + * Portability note: The reason this function exists is because a 64-bit + * sscanf is not available in all environments. + * + *****************************************************************************/ + +ACPI_STATUS +DtStrtoul64 ( + char *String, + UINT64 *ReturnInteger) +{ + char *ThisChar = String; + UINT32 ThisDigit; + UINT64 ReturnValue = 0; + int DigitCount = 0; + + + /* Skip over any white space in the buffer */ + + while ((*ThisChar == ' ') || (*ThisChar == '\t')) + { + ThisChar++; + } + + /* Skip leading zeros */ + + while ((*ThisChar) == '0') + { + ThisChar++; + } + + /* Convert character-by-character */ + + while (*ThisChar) + { + if (ACPI_IS_DIGIT (*ThisChar)) + { + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *ThisChar) - '0'; + } + else /* Letter */ + { + ThisDigit = (UINT32) ACPI_TOUPPER (*ThisChar); + if (!ACPI_IS_XDIGIT ((char) ThisDigit)) + { + /* Not A-F */ + + return (AE_BAD_CHARACTER); + } + + /* Convert ASCII Hex char (A-F) to value */ + + ThisDigit = (ThisDigit - 'A') + 10; + } + + /* Insert the 4-bit hex digit */ + + ReturnValue <<= 4; + ReturnValue += ThisDigit; + + ThisChar++; + DigitCount++; + if (DigitCount > 16) + { + /* Value is too large (> 64 bits/8 bytes/16 hex digits) */ + + return (AE_LIMIT); + } + } + + *ReturnInteger = ReturnValue; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetFileSize + * + * PARAMETERS: Handle - Open file handler + * + * RETURN: Current file size + * + * DESCRIPTION: Get the current size of a file. Seek to the EOF and get the + * offset. Seek back to the original location. + * + *****************************************************************************/ + +UINT32 +DtGetFileSize ( + FILE *Handle) +{ + int CurrentOffset; + int LastOffset; + + + CurrentOffset = ftell (Handle); + fseek (Handle, 0, SEEK_END); + LastOffset = ftell (Handle); + fseek (Handle, CurrentOffset, SEEK_SET); + + return ((UINT32) LastOffset); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetFieldValue + * + * PARAMETERS: Field - Current field list pointer + * Name - Field name + * + * RETURN: Field value + * + * DESCRIPTION: Get field value + * + *****************************************************************************/ + +char * +DtGetFieldValue ( + DT_FIELD *Field, + char *Name) +{ + + /* Search the field list for the name */ + + while (Field) + { + if (!ACPI_STRCMP (Name, Field->Name)) + { + return (Field->Value); + } + + Field = Field->Next; + } + + return (NULL); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetFieldType + * + * PARAMETERS: Info - Data table info + * + * RETURN: Field type + * + * DESCRIPTION: Get field type + * + *****************************************************************************/ + +UINT8 +DtGetFieldType ( + ACPI_DMTABLE_INFO *Info) +{ + UINT8 Type; + + + /* DT_FLAG means that this is the start of a block of flag bits */ + /* TBD - we can make these a separate opcode later */ + + if (Info->Flags & DT_FLAG) + { + return (DT_FIELD_TYPE_FLAGS_INTEGER); + } + + /* Type is based upon the opcode for this field in the info table */ + + switch (Info->Opcode) + { + case ACPI_DMT_FLAG0: + case ACPI_DMT_FLAG1: + case ACPI_DMT_FLAG2: + case ACPI_DMT_FLAG3: + case ACPI_DMT_FLAG4: + case ACPI_DMT_FLAG5: + case ACPI_DMT_FLAG6: + case ACPI_DMT_FLAG7: + case ACPI_DMT_FLAGS0: + case ACPI_DMT_FLAGS2: + Type = DT_FIELD_TYPE_FLAG; + break; + + case ACPI_DMT_NAME4: + case ACPI_DMT_SIG: + case ACPI_DMT_NAME6: + case ACPI_DMT_NAME8: + case ACPI_DMT_STRING: + Type = DT_FIELD_TYPE_STRING; + break; + + case ACPI_DMT_BUFFER: + case ACPI_DMT_BUF7: + case ACPI_DMT_BUF16: + case ACPI_DMT_PCI_PATH: + Type = DT_FIELD_TYPE_BUFFER; + break; + + case ACPI_DMT_GAS: + case ACPI_DMT_HESTNTFY: + Type = DT_FIELD_TYPE_INLINE_SUBTABLE; + break; + + case ACPI_DMT_UNICODE: + Type = DT_FIELD_TYPE_UNICODE; + break; + + case ACPI_DMT_UUID: + Type = DT_FIELD_TYPE_UUID; + break; + + case ACPI_DMT_DEVICE_PATH: + Type = DT_FIELD_TYPE_DEVICE_PATH; + break; + + case ACPI_DMT_LABEL: + Type = DT_FIELD_TYPE_LABEL; + break; + + default: + Type = DT_FIELD_TYPE_INTEGER; + break; + } + + return (Type); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetBufferLength + * + * PARAMETERS: Buffer - List of integers, + * for example "10 3A 4F 2E" + * + * RETURN: Count of integer + * + * DESCRIPTION: Get length of bytes needed to store the integers + * + *****************************************************************************/ + +UINT32 +DtGetBufferLength ( + char *Buffer) +{ + UINT32 ByteLength = 0; + + + while (*Buffer) + { + if (*Buffer == ' ') + { + ByteLength++; + + while (*Buffer == ' ') + { + Buffer++; + } + } + + Buffer++; + } + + return (++ByteLength); +} + + +/****************************************************************************** + * + * FUNCTION: DtGetFieldLength + * + * PARAMETERS: Field - Current field list pointer + * Info - Data table info + * + * RETURN: Field length + * + * DESCRIPTION: Get length of bytes needed to compile the field + * + * Note: This function must remain in sync with AcpiDmDumpTable. + * + *****************************************************************************/ + +UINT32 +DtGetFieldLength ( + DT_FIELD *Field, + ACPI_DMTABLE_INFO *Info) +{ + UINT32 ByteLength = 0; + char *Value; + + + /* Length is based upon the opcode for this field in the info table */ + + switch (Info->Opcode) + { + case ACPI_DMT_FLAG0: + case ACPI_DMT_FLAG1: + case ACPI_DMT_FLAG2: + case ACPI_DMT_FLAG3: + case ACPI_DMT_FLAG4: + case ACPI_DMT_FLAG5: + case ACPI_DMT_FLAG6: + case ACPI_DMT_FLAG7: + case ACPI_DMT_FLAGS0: + case ACPI_DMT_FLAGS2: + case ACPI_DMT_LABEL: + ByteLength = 0; + break; + + case ACPI_DMT_UINT8: + case ACPI_DMT_CHKSUM: + case ACPI_DMT_SPACEID: + case ACPI_DMT_ACCWIDTH: + case ACPI_DMT_IVRS: + case ACPI_DMT_MADT: + case ACPI_DMT_SRAT: + case ACPI_DMT_ASF: + case ACPI_DMT_HESTNTYP: + case ACPI_DMT_FADTPM: + case ACPI_DMT_EINJACT: + case ACPI_DMT_EINJINST: + case ACPI_DMT_ERSTACT: + case ACPI_DMT_ERSTINST: + ByteLength = 1; + break; + + case ACPI_DMT_UINT16: + case ACPI_DMT_DMAR: + case ACPI_DMT_HEST: + case ACPI_DMT_PCI_PATH: + ByteLength = 2; + break; + + case ACPI_DMT_UINT24: + ByteLength = 3; + break; + + case ACPI_DMT_UINT32: + case ACPI_DMT_NAME4: + case ACPI_DMT_SIG: + ByteLength = 4; + break; + + case ACPI_DMT_NAME6: + ByteLength = 6; + break; + + case ACPI_DMT_UINT56: + case ACPI_DMT_BUF7: + ByteLength = 7; + break; + + case ACPI_DMT_UINT64: + case ACPI_DMT_NAME8: + ByteLength = 8; + break; + + case ACPI_DMT_STRING: + Value = DtGetFieldValue (Field, Info->Name); + if (Value) + { + ByteLength = ACPI_STRLEN (Value) + 1; + } + else + { /* At this point, this is a fatal error */ + + sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); + DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); + } + break; + + case ACPI_DMT_GAS: + ByteLength = sizeof (ACPI_GENERIC_ADDRESS); + break; + + case ACPI_DMT_HESTNTFY: + ByteLength = sizeof (ACPI_HEST_NOTIFY); + break; + + case ACPI_DMT_BUFFER: + Value = DtGetFieldValue (Field, Info->Name); + if (Value) + { + ByteLength = DtGetBufferLength (Value); + } + else + { /* At this point, this is a fatal error */ + + sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); + DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); + } + break; + + case ACPI_DMT_BUF16: + case ACPI_DMT_UUID: + ByteLength = 16; + break; + + case ACPI_DMT_UNICODE: + Value = DtGetFieldValue (Field, Info->Name); + + /* TBD: error if Value is NULL? (as below?) */ + + ByteLength = (ACPI_STRLEN (Value) + 1) * sizeof(UINT16); + break; + + default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode"); + break; + } + + return (ByteLength); +} + + +/****************************************************************************** + * + * FUNCTION: DtSum + * + * PARAMETERS: DT_WALK_CALLBACK: + * Subtable - Subtable + * Context - Unused + * ReturnValue - Store the checksum of subtable + * + * RETURN: Status + * + * DESCRIPTION: Get the checksum of subtable + * + *****************************************************************************/ + +static void +DtSum ( + DT_SUBTABLE *Subtable, + void *Context, + void *ReturnValue) +{ + UINT8 Checksum; + UINT8 *Sum = ReturnValue; + + + Checksum = AcpiTbChecksum (Subtable->Buffer, Subtable->Length); + *Sum = (UINT8) (*Sum + Checksum); +} + + +/****************************************************************************** + * + * FUNCTION: DtSetTableChecksum + * + * PARAMETERS: ChecksumPointer - Where to return the checksum + * + * RETURN: None + * + * DESCRIPTION: Set checksum of the whole data table into the checksum field + * + *****************************************************************************/ + +void +DtSetTableChecksum ( + UINT8 *ChecksumPointer) +{ + UINT8 Checksum = 0; + UINT8 OldSum; + + + DtWalkTableTree (Gbl_RootTable, DtSum, NULL, &Checksum); + + OldSum = *ChecksumPointer; + Checksum = (UINT8) (Checksum - OldSum); + + /* Compute the final checksum */ + + Checksum = (UINT8) (0 - Checksum); + *ChecksumPointer = Checksum; +} + + +/****************************************************************************** + * + * FUNCTION: DtSetTableLength + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Walk the subtables and set all the length fields + * + *****************************************************************************/ + +void +DtSetTableLength ( + void) +{ + DT_SUBTABLE *ParentTable; + DT_SUBTABLE *ChildTable; + + + ParentTable = Gbl_RootTable; + ChildTable = NULL; + + if (!ParentTable) + { + return; + } + + DtSetSubtableLength (ParentTable); + + while (1) + { + ChildTable = DtGetNextSubtable (ParentTable, ChildTable); + if (ChildTable) + { + if (ChildTable->LengthField) + { + DtSetSubtableLength (ChildTable); + } + + if (ChildTable->Child) + { + ParentTable = ChildTable; + ChildTable = NULL; + } + else + { + ParentTable->TotalLength += ChildTable->TotalLength; + if (ParentTable->LengthField) + { + DtSetSubtableLength (ParentTable); + } + } + } + else + { + ChildTable = ParentTable; + + if (ChildTable == Gbl_RootTable) + { + break; + } + + ParentTable = DtGetParentSubtable (ParentTable); + + ParentTable->TotalLength += ChildTable->TotalLength; + if (ParentTable->LengthField) + { + DtSetSubtableLength (ParentTable); + } + } + } +} + + +/****************************************************************************** + * + * FUNCTION: DtWalkTableTree + * + * PARAMETERS: StartTable - Subtable in the tree where walking begins + * UserFunction - Called during the walk + * Context - Passed to user function + * ReturnValue - The return value of UserFunction + * + * RETURN: None + * + * DESCRIPTION: Performs a depth-first walk of the subtable tree + * + *****************************************************************************/ + +void +DtWalkTableTree ( + DT_SUBTABLE *StartTable, + DT_WALK_CALLBACK UserFunction, + void *Context, + void *ReturnValue) +{ + DT_SUBTABLE *ParentTable; + DT_SUBTABLE *ChildTable; + + + ParentTable = StartTable; + ChildTable = NULL; + + if (!ParentTable) + { + return; + } + + UserFunction (ParentTable, Context, ReturnValue); + + while (1) + { + ChildTable = DtGetNextSubtable (ParentTable, ChildTable); + if (ChildTable) + { + UserFunction (ChildTable, Context, ReturnValue); + + if (ChildTable->Child) + { + ParentTable = ChildTable; + ChildTable = NULL; + } + } + else + { + ChildTable = ParentTable; + if (ChildTable == Gbl_RootTable) + { + break; + } + + ParentTable = DtGetParentSubtable (ParentTable); + + if (ChildTable->Peer == StartTable) + { + break; + } + } + } +} + + +/****************************************************************************** + * + * FUNCTION: DtFreeFieldList + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free the field list + * + *****************************************************************************/ + +void +DtFreeFieldList ( + void) +{ + DT_FIELD *Field = Gbl_FieldList; + DT_FIELD *NextField; + + + /* Walk and free entire field list */ + + while (Field) + { + NextField = Field->Next; /* Save link */ + + if (!(Field->Flags & DT_FIELD_NOT_ALLOCATED)) + { + ACPI_FREE (Field->Name); + ACPI_FREE (Field->Value); + } + + ACPI_FREE (Field); + Field = NextField; + } +} diff --git a/sys/contrib/dev/acpica-unix/debugger/dbcmds.c b/sys/contrib/dev/acpica-unix/debugger/dbcmds.c index a316b4292c..21bccc16ca 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbcmds.c @@ -1,6 +1,6 @@ /******************************************************************************* * - * Module Name: dbcmds - debug commands and output routines + * Module Name: dbcmds - Miscellaneous debug commands and output routines * ******************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,53 +116,18 @@ #include "acpi.h" #include "accommon.h" -#include "acdispat.h" -#include "acnamesp.h" #include "acevents.h" #include "acdebug.h" #include "acresrc.h" -#include "acdisasm.h" #include "actables.h" -#include "acparser.h" #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbcmds") -/* Local prototypes */ - -static ACPI_STATUS -AcpiDbIntegrityWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiDbWalkAndMatchName ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiDbWalkForReferences ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -static ACPI_STATUS -AcpiDbWalkForSpecificObjects ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); -static ACPI_NAMESPACE_NODE * -AcpiDbConvertToNode ( - char *InString); +/* Local prototypes */ static void AcpiDmCompareAmlResources ( @@ -177,38 +142,6 @@ AcpiDmTestResourceConversion ( char *Name); -/* - * Arguments for the Objects command - * These object types map directly to the ACPI_TYPES - */ -static ARGUMENT_INFO AcpiDbObjectTypes [] = -{ - {"ANY"}, - {"INTEGERS"}, - {"STRINGS"}, - {"BUFFERS"}, - {"PACKAGES"}, - {"FIELDS"}, - {"DEVICES"}, - {"EVENTS"}, - {"METHODS"}, - {"MUTEXES"}, - {"REGIONS"}, - {"POWERRESOURCES"}, - {"PROCESSORS"}, - {"THERMALZONES"}, - {"BUFFERFIELDS"}, - {"DDBHANDLES"}, - {"DEBUG"}, - {"REGIONFIELDS"}, - {"BANKFIELDS"}, - {"INDEXFIELDS"}, - {"REFERENCES"}, - {"ALIAS"}, - {NULL} /* Must be null terminated */ -}; - - /******************************************************************************* * * FUNCTION: AcpiDbConvertToNode @@ -222,7 +155,7 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = * ******************************************************************************/ -static ACPI_NAMESPACE_NODE * +ACPI_NAMESPACE_NODE * AcpiDbConvertToNode ( char *InString) { @@ -309,305 +242,6 @@ AcpiDbSleep ( return (Status); } - -/******************************************************************************* - * - * FUNCTION: AcpiDbWalkForReferences - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Check if this namespace object refers to the target object - * that is passed in as the context value. - * - * Note: Currently doesn't check subobjects within the Node's object - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbWalkForReferences ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - - - /* Check for match against the namespace node itself */ - - if (Node == (void *) ObjDesc) - { - AcpiOsPrintf ("Object is a Node [%4.4s]\n", - AcpiUtGetNodeName (Node)); - } - - /* Check for match against the object attached to the node */ - - if (AcpiNsGetAttachedObject (Node) == ObjDesc) - { - AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", - Node, AcpiUtGetNodeName (Node)); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbFindReferences - * - * PARAMETERS: ObjectArg - String with hex value of the object - * - * RETURN: None - * - * DESCRIPTION: Search namespace for all references to the input object - * - ******************************************************************************/ - -void -AcpiDbFindReferences ( - char *ObjectArg) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - - - /* Convert string to object pointer */ - - ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); - - /* Search all nodes in namespace */ - - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForReferences, (void *) ObjDesc, NULL); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbWalkForPredefinedNames - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Detect and display predefined ACPI names (names that start with - * an underscore) - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbWalkForPredefinedNames ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - UINT32 *Count = (UINT32 *) Context; - const ACPI_PREDEFINED_INFO *Predefined; - const ACPI_PREDEFINED_INFO *Package = NULL; - char *Pathname; - - - Predefined = AcpiNsCheckForPredefinedName (Node); - if (!Predefined) - { - return (AE_OK); - } - - Pathname = AcpiNsGetExternalPathname (Node); - if (!Pathname) - { - return (AE_OK); - } - - /* If method returns a package, the info is in the next table entry */ - - if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE) - { - Package = Predefined + 1; - } - - AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname, - Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes); - - if (Package) - { - AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X", - Package->RetInfo.Type, Package->RetInfo.ObjectType1, - Package->RetInfo.Count1); - } - - AcpiOsPrintf("\n"); - - AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined); - ACPI_FREE (Pathname); - (*Count)++; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbCheckPredefinedNames - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Validate all predefined names in the namespace - * - ******************************************************************************/ - -void -AcpiDbCheckPredefinedNames ( - void) -{ - UINT32 Count = 0; - - - /* Search all nodes in namespace */ - - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForPredefinedNames, (void *) &Count, NULL); - - AcpiOsPrintf ("Found %d predefined names in the namespace\n", Count); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbWalkForExecute - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Batch execution module. Currently only executes predefined - * ACPI names. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbWalkForExecute ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - UINT32 *Count = (UINT32 *) Context; - const ACPI_PREDEFINED_INFO *Predefined; - ACPI_BUFFER ReturnObj; - ACPI_STATUS Status; - char *Pathname; - ACPI_BUFFER Buffer; - UINT32 i; - ACPI_DEVICE_INFO *ObjInfo; - ACPI_OBJECT_LIST ParamObjects; - ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; - - - Predefined = AcpiNsCheckForPredefinedName (Node); - if (!Predefined) - { - return (AE_OK); - } - - if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) - { - return (AE_OK); - } - - Pathname = AcpiNsGetExternalPathname (Node); - if (!Pathname) - { - return (AE_OK); - } - - /* Get the object info for number of method parameters */ - - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (ObjHandle, &Buffer); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParamObjects.Pointer = NULL; - ParamObjects.Count = 0; - - ObjInfo = Buffer.Pointer; - if (ObjInfo->Type == ACPI_TYPE_METHOD) - { - - /* Setup default parameters */ - - for (i = 0; i < ObjInfo->ParamCount; i++) - { - Params[i].Type = ACPI_TYPE_INTEGER; - Params[i].Integer.Value = 1; - } - - ParamObjects.Pointer = Params; - ParamObjects.Count = ObjInfo->ParamCount; - } - - ACPI_FREE (Buffer.Pointer); - - ReturnObj.Pointer = NULL; - ReturnObj.Length = ACPI_ALLOCATE_BUFFER; - - - /* Do the actual method execution */ - - AcpiGbl_MethodExecuting = TRUE; - - Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); - - AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); - AcpiGbl_MethodExecuting = FALSE; - - ACPI_FREE (Pathname); - (*Count)++; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbBatchExecute - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Namespace batch execution. - * - ******************************************************************************/ - -void -AcpiDbBatchExecute ( - void) -{ - UINT32 Count = 0; - - - /* Search all nodes in namespace */ - - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForExecute, (void *) &Count, NULL); - - AcpiOsPrintf ("Executed %d predefined names in the namespace\n", Count); -} - - /******************************************************************************* * * FUNCTION: AcpiDbDisplayLocks @@ -660,841 +294,235 @@ AcpiDbDisplayTableInfo ( /* Walk the entire root table list */ - for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { TableDesc = &AcpiGbl_RootTableList.Tables[i]; - AcpiOsPrintf ("%d ", i); + AcpiOsPrintf ("%u ", i); /* Make sure that the table is mapped */ Status = AcpiTbVerifyTable (TableDesc); if (ACPI_FAILURE (Status)) { - return; - } - - /* Dump the table header */ - - if (TableDesc->Pointer) - { - AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); - } - else - { - /* If the pointer is null, the table has been unloaded */ - - ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", - TableDesc->Signature.Ascii)); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbUnloadAcpiTable - * - * PARAMETERS: TableArg - Name of the table to be unloaded - * InstanceArg - Which instance of the table to unload (if - * there are multiple tables of the same type) - * - * RETURN: Nonde - * - * DESCRIPTION: Unload an ACPI table. - * Instance is not implemented - * - ******************************************************************************/ - -void -AcpiDbUnloadAcpiTable ( - char *TableArg, - char *InstanceArg) -{ -/* TBD: Need to reimplement for new data structures */ - -#if 0 - UINT32 i; - ACPI_STATUS Status; - - - /* Search all tables for the target type */ - - for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) - { - if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, - AcpiGbl_TableData[i].SigLength)) - { - /* Found the table, unload it */ - - Status = AcpiUnloadTable (i); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); - } - else - { - AcpiOsPrintf ("%s, while unloading [%s]\n", - AcpiFormatException (Status), TableArg); - } - - return; - } - } - - AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); -#endif -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbSetMethodBreakpoint - * - * PARAMETERS: Location - AML offset of breakpoint - * WalkState - Current walk info - * Op - Current Op (from parse walk) - * - * RETURN: None - * - * DESCRIPTION: Set a breakpoint in a control method at the specified - * AML offset - * - ******************************************************************************/ - -void -AcpiDbSetMethodBreakpoint ( - char *Location, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op) -{ - UINT32 Address; - - - if (!Op) - { - AcpiOsPrintf ("There is no method currently executing\n"); - return; - } - - /* Get and verify the breakpoint address */ - - Address = ACPI_STRTOUL (Location, NULL, 16); - if (Address <= Op->Common.AmlOffset) - { - AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", - Address, Op->Common.AmlOffset); - } - - /* Save breakpoint in current walk */ - - WalkState->UserBreakpoint = Address; - AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbSetMethodCallBreakpoint - * - * PARAMETERS: Op - Current Op (from parse walk) - * - * RETURN: None - * - * DESCRIPTION: Set a breakpoint in a control method at the specified - * AML offset - * - ******************************************************************************/ - -void -AcpiDbSetMethodCallBreakpoint ( - ACPI_PARSE_OBJECT *Op) -{ - - - if (!Op) - { - AcpiOsPrintf ("There is no method currently executing\n"); - return; - } - - AcpiGbl_StepToNextCall = TRUE; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDisassembleAml - * - * PARAMETERS: Statements - Number of statements to disassemble - * Op - Current Op (from parse walk) - * - * RETURN: None - * - * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number - * of statements specified. - * - ******************************************************************************/ - -void -AcpiDbDisassembleAml ( - char *Statements, - ACPI_PARSE_OBJECT *Op) -{ - UINT32 NumStatements = 8; - - - if (!Op) - { - AcpiOsPrintf ("There is no method currently executing\n"); - return; - } - - if (Statements) - { - NumStatements = ACPI_STRTOUL (Statements, NULL, 0); - } - - AcpiDmDisassemble (NULL, Op, NumStatements); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDisassembleMethod - * - * PARAMETERS: Name - Name of control method - * - * RETURN: None - * - * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number - * of statements specified. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDbDisassembleMethod ( - char *Name) -{ - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *Op; - ACPI_WALK_STATE *WalkState; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Method; - - - Method = AcpiDbConvertToNode (Name); - if (!Method) - { - return (AE_BAD_PARAMETER); - } - - ObjDesc = Method->Object; - - Op = AcpiPsCreateScopeOp (); - if (!Op) - { - return (AE_NO_MEMORY); - } - - /* Create and initialize a new walk state */ - - WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); - if (!WalkState) - { - return (AE_NO_MEMORY); - } - - Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, - ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Parse the AML */ - - WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; - WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; - Status = AcpiPsParseAml (WalkState); - - AcpiDmDisassemble (NULL, Op, 0); - AcpiPsDeleteParseTree (Op); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDumpNamespace - * - * PARAMETERS: StartArg - Node to begin namespace dump - * DepthArg - Maximum tree depth to be dumped - * - * RETURN: None - * - * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed - * with type and other information. - * - ******************************************************************************/ - -void -AcpiDbDumpNamespace ( - char *StartArg, - char *DepthArg) -{ - ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; - UINT32 MaxDepth = ACPI_UINT32_MAX; - - - /* No argument given, just start at the root and dump entire namespace */ - - if (StartArg) - { - SubtreeEntry = AcpiDbConvertToNode (StartArg); - if (!SubtreeEntry) - { - return; - } - - /* Now we can check for the depth argument */ - - if (DepthArg) - { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); - } - } - - AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", - ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); - - /* Display the subtree */ - - AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, - ACPI_OWNER_ID_MAX, SubtreeEntry); - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDumpNamespaceByOwner - * - * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed - * DepthArg - Maximum tree depth to be dumped - * - * RETURN: None - * - * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. - * - ******************************************************************************/ - -void -AcpiDbDumpNamespaceByOwner ( - char *OwnerArg, - char *DepthArg) -{ - ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; - UINT32 MaxDepth = ACPI_UINT32_MAX; - ACPI_OWNER_ID OwnerId; - - - OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); - - /* Now we can check for the depth argument */ - - if (DepthArg) - { - MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); - } - - AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); - - /* Display the subtree */ - - AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, - SubtreeEntry); - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbSendNotify - * - * PARAMETERS: Name - Name of ACPI object to send the notify to - * Value - Value of the notify to send. - * - * RETURN: None - * - * DESCRIPTION: Send an ACPI notification. The value specified is sent to the - * named object as an ACPI notify. - * - ******************************************************************************/ - -void -AcpiDbSendNotify ( - char *Name, - UINT32 Value) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - /* Translate name to an Named object */ - - Node = AcpiDbConvertToNode (Name); - if (!Node) - { - return; - } - - /* Decode Named object type */ - - switch (Node->Type) - { - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_THERMAL: - - /* Send the notify */ - - Status = AcpiEvQueueNotifyRequest (Node, Value); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not queue notify\n"); - } - break; - - default: - AcpiOsPrintf ("Named object is not a device or a thermal object\n"); - break; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbSetMethodData - * - * PARAMETERS: TypeArg - L for local, A for argument - * IndexArg - which one - * ValueArg - Value to set. - * - * RETURN: None - * - * DESCRIPTION: Set a local or argument for the running control method. - * NOTE: only object supported is Number. - * - ******************************************************************************/ - -void -AcpiDbSetMethodData ( - char *TypeArg, - char *IndexArg, - char *ValueArg) -{ - char Type; - UINT32 Index; - UINT32 Value; - ACPI_WALK_STATE *WalkState; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - - - /* Validate TypeArg */ - - AcpiUtStrupr (TypeArg); - Type = TypeArg[0]; - if ((Type != 'L') && - (Type != 'A') && - (Type != 'N')) - { - AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); - return; - } - - Value = ACPI_STRTOUL (ValueArg, NULL, 16); - - if (Type == 'N') - { - Node = AcpiDbConvertToNode (IndexArg); - if (Node->Type != ACPI_TYPE_INTEGER) - { - AcpiOsPrintf ("Can only set Integer nodes\n"); - return; - } - ObjDesc = Node->Object; - ObjDesc->Integer.Value = Value; - return; - } - - /* Get the index and value */ - - Index = ACPI_STRTOUL (IndexArg, NULL, 16); - - WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); - if (!WalkState) - { - AcpiOsPrintf ("There is no method currently executing\n"); - return; - } - - /* Create and initialize the new object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ObjDesc) - { - AcpiOsPrintf ("Could not create an internal object\n"); - return; - } - - ObjDesc->Integer.Value = Value; - - /* Store the new object into the target */ - - switch (Type) - { - case 'A': - - /* Set a method argument */ - - if (Index > ACPI_METHOD_MAX_ARG) - { - AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); - goto Cleanup; - } - - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, - WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - ObjDesc = WalkState->Arguments[Index].Object; - - AcpiOsPrintf ("Arg%d: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); - break; - - case 'L': - - /* Set a method local */ - - if (Index > ACPI_METHOD_MAX_LOCAL) - { - AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); - goto Cleanup; - } - - Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, - WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - ObjDesc = WalkState->LocalVariables[Index].Object; - - AcpiOsPrintf ("Local%d: ", Index); - AcpiDmDisplayInternalObject (ObjDesc, WalkState); - break; - - default: - break; - } - -Cleanup: - AcpiUtRemoveReference (ObjDesc); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbWalkForSpecificObjects - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Display short info about objects in the namespace - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbWalkForSpecificObjects ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; - ACPI_BUFFER Buffer; - ACPI_STATUS Status; - - - Info->Count++; - - /* Get and display the full pathname to this object */ - - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); - return (AE_OK); - } - - AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); - ACPI_FREE (Buffer.Pointer); - - /* Dump short info about the object */ - - (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDisplayObjects - * - * PARAMETERS: ObjTypeArg - Type of object to display - * DisplayCountArg - Max depth to display - * - * RETURN: None - * - * DESCRIPTION: Display objects in the namespace of the requested type - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDbDisplayObjects ( - char *ObjTypeArg, - char *DisplayCountArg) -{ - ACPI_WALK_INFO Info; - ACPI_OBJECT_TYPE Type; - - - /* Get the object type */ - - Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); - if (Type == ACPI_TYPE_NOT_FOUND) - { - AcpiOsPrintf ("Invalid or unsupported argument\n"); - return (AE_OK); - } - - AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ( - "Objects of type [%s] defined in the current ACPI Namespace:\n", - AcpiUtGetTypeName (Type)); - - AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - - Info.Count = 0; - Info.OwnerId = ACPI_OWNER_ID_MAX; - Info.DebugLevel = ACPI_UINT32_MAX; - Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; - - /* Walk the namespace from the root */ + return; + } - (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForSpecificObjects, (void *) &Info, NULL); + /* Dump the table header */ - AcpiOsPrintf ( - "\nFound %u objects of type [%s] in the current ACPI Namespace\n", - Info.Count, AcpiUtGetTypeName (Type)); + if (TableDesc->Pointer) + { + AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); + } + else + { + /* If the pointer is null, the table has been unloaded */ - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); - return (AE_OK); + ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", + TableDesc->Signature.Ascii)); + } + } } /******************************************************************************* * - * FUNCTION: AcpiDbWalkAndMatchName + * FUNCTION: AcpiDbUnloadAcpiTable * - * PARAMETERS: Callback from WalkNamespace + * 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: Status + * RETURN: Nonde * - * DESCRIPTION: Find a particular name/names within the namespace. Wildcards - * are supported -- '?' matches any character. + * DESCRIPTION: Unload an ACPI table. + * Instance is not implemented * ******************************************************************************/ -static ACPI_STATUS -AcpiDbWalkAndMatchName ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) +void +AcpiDbUnloadAcpiTable ( + char *TableArg, + char *InstanceArg) { - ACPI_STATUS Status; - char *RequestedName = (char *) Context; +/* TBD: Need to reimplement for new data structures */ + +#if 0 UINT32 i; - ACPI_BUFFER Buffer; - ACPI_WALK_INFO Info; + ACPI_STATUS Status; - /* Check for a name match */ + /* Search all tables for the target type */ - for (i = 0; i < 4; i++) + for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) { - /* Wildcard support */ - - if ((RequestedName[i] != '?') && - (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) + if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, + AcpiGbl_TableData[i].SigLength)) { - /* No match, just exit */ - - return (AE_OK); - } - } - - /* Get the full pathname to this object */ + /* Found the table, unload it */ - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); - } - else - { - Info.OwnerId = ACPI_OWNER_ID_MAX; - Info.DebugLevel = ACPI_UINT32_MAX; - Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; + Status = AcpiUnloadTable (i); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); + } + else + { + AcpiOsPrintf ("%s, while unloading [%s]\n", + AcpiFormatException (Status), TableArg); + } - AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); - (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); - ACPI_FREE (Buffer.Pointer); + return; + } } - return (AE_OK); + AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); +#endif } /******************************************************************************* * - * FUNCTION: AcpiDbFindNameInNamespace + * FUNCTION: AcpiDbSendNotify * - * PARAMETERS: NameArg - The 4-character ACPI name to find. - * wildcards are supported. + * PARAMETERS: Name - Name of ACPI object to send the notify to + * Value - Value of the notify to send. * * RETURN: None * - * DESCRIPTION: Search the namespace for a given name (with wildcards) + * DESCRIPTION: Send an ACPI notification. The value specified is sent to the + * named object as an ACPI notify. * ******************************************************************************/ -ACPI_STATUS -AcpiDbFindNameInNamespace ( - char *NameArg) +void +AcpiDbSendNotify ( + char *Name, + UINT32 Value) { - char AcpiName[5] = "____"; - char *AcpiNamePtr = AcpiName; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; - if (ACPI_STRLEN (NameArg) > 4) + /* Translate name to an Named object */ + + Node = AcpiDbConvertToNode (Name); + if (!Node) { - AcpiOsPrintf ("Name must be no longer than 4 characters\n"); - return (AE_OK); + return; } - /* Pad out name with underscores as necessary to create a 4-char name */ + /* Decode Named object type */ - AcpiUtStrupr (NameArg); - while (*NameArg) + switch (Node->Type) { - *AcpiNamePtr = *NameArg; - AcpiNamePtr++; - NameArg++; - } + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: - /* Walk the namespace from the root */ + /* Send the notify */ - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkAndMatchName, AcpiName, NULL); + Status = AcpiEvQueueNotifyRequest (Node, Value); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not queue notify\n"); + } + break; - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); - return (AE_OK); + default: + AcpiOsPrintf ("Named object is not a device or a thermal object\n"); + break; + } } /******************************************************************************* * - * FUNCTION: AcpiDbSetScope + * FUNCTION: AcpiDbDisplayInterfaces * - * PARAMETERS: Name - New scope path + * PARAMETERS: ActionArg - Null, "install", or "remove" + * InterfaceNameArg - Name for install/remove options * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Set the "current scope" as maintained by this utility. - * The scope is used as a prefix to ACPI paths. + * DESCRIPTION: Display or modify the global _OSI interface list * ******************************************************************************/ void -AcpiDbSetScope ( - char *Name) +AcpiDbDisplayInterfaces ( + char *ActionArg, + char *InterfaceNameArg) { + ACPI_INTERFACE_INFO *NextInterface; + char *SubString; ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - if (!Name || Name[0] == 0) + /* If no arguments, just display current interface list */ + + if (!ActionArg) { - AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, + ACPI_WAIT_FOREVER); + + NextInterface = AcpiGbl_SupportedInterfaces; + + while (NextInterface) + { + if (!(NextInterface->Flags & ACPI_OSI_INVALID)) + { + AcpiOsPrintf ("%s\n", NextInterface->Name); + } + NextInterface = NextInterface->Next; + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); return; } - AcpiDbPrepNamestring (Name); + /* If ActionArg exists, so must InterfaceNameArg */ - if (Name[0] == '\\') + if (!InterfaceNameArg) { - /* Validate new scope from the root */ + AcpiOsPrintf ("Missing Interface Name argument\n"); + return; + } + + /* Uppercase the action for match below */ + + AcpiUtStrupr (ActionArg); - Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + /* Install - install an interface */ + + SubString = ACPI_STRSTR ("INSTALL", ActionArg); + if (SubString) + { + Status = AcpiInstallInterface (InterfaceNameArg); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + AcpiOsPrintf ("%s, while installing \"%s\"\n", + AcpiFormatException (Status), InterfaceNameArg); } - - ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + return; } - else - { - /* Validate new scope relative to old scope */ - Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, - &Node); + /* Remove - remove an interface */ + + SubString = ACPI_STRSTR ("REMOVE", ActionArg); + if (SubString) + { + Status = AcpiRemoveInterface (InterfaceNameArg); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + AcpiOsPrintf ("%s, while removing \"%s\"\n", + AcpiFormatException (Status), InterfaceNameArg); } - - ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + return; } - AcpiGbl_DbScopeNode = Node; - AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); - return; - -ErrorExit: + /* Invalid ActionArg */ - AcpiOsPrintf ("Could not attach scope: %s, %s\n", - Name, AcpiFormatException (Status)); + AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg); + return; } @@ -1824,112 +852,6 @@ Cleanup: } -/******************************************************************************* - * - * FUNCTION: AcpiDbIntegrityWalk - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Examine one NS node for valid values. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbIntegrityWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_OPERAND_OBJECT *Object; - BOOLEAN Alias = TRUE; - - - Info->Nodes++; - - /* Verify the NS node, and dereference aliases */ - - while (Alias) - { - if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) - { - AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n", - Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node), - ACPI_DESC_TYPE_NAMED); - return (AE_OK); - } - - if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) || - (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) - { - Node = (ACPI_NAMESPACE_NODE *) Node->Object; - } - else - { - Alias = FALSE; - } - } - - if (Node->Type > ACPI_TYPE_LOCAL_MAX) - { - AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", - Node, Node->Type); - return (AE_OK); - } - - if (!AcpiUtValidAcpiName (Node->Name.Integer)) - { - AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); - return (AE_OK); - } - - Object = AcpiNsGetAttachedObject (Node); - if (Object) - { - Info->Objects++; - if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) - { - AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", - Object, AcpiUtGetDescriptorName (Object)); - } - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbCheckIntegrity - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Check entire namespace for data structure integrity - * - ******************************************************************************/ - -void -AcpiDbCheckIntegrity ( - void) -{ - ACPI_INTEGRITY_INFO Info = {0,0}; - - /* Search all nodes in namespace */ - - (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbIntegrityWalk, (void *) &Info, NULL); - - AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", - Info.Nodes, Info.Objects); -} - - /******************************************************************************* * * FUNCTION: AcpiDbGenerateGpe @@ -1966,133 +888,7 @@ AcpiDbGenerateGpe ( return; } - (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbBusWalk - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Display info about device objects that have a corresponding - * _PRT method. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbBusWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue) -{ - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_STATUS Status; - ACPI_BUFFER Buffer; - ACPI_INTEGER ADR; - ACPI_DEVICE_ID Id; - ACPI_COMPATIBLE_ID_LIST *Cid; - ACPI_NAMESPACE_NODE *TempNode; - - - /* Exit if there is no _PRT under this device */ - - Status = AcpiGetHandle (Node, METHOD_NAME__PRT, - ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); - if (ACPI_FAILURE (Status)) - { - return (AE_OK); - } - - /* Get the full path to this device object */ - - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); - return (AE_OK); - } - - /* Display the full path */ - - AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer); - ACPI_FREE (Buffer.Pointer); - - /* _PRT info */ - - AcpiOsPrintf ("_PRT=%p", TempNode); - - /* Get the _ADR value */ - - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf (" No _ADR "); - } - else - { - AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR); - } - - /* Get the _HID if present */ - - Status = AcpiUtExecute_HID (Node, &Id); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf (" _HID=%s", Id.Value); - } - else - { - AcpiOsPrintf (" "); - } - - /* Get the _UID if present */ - - Status = AcpiUtExecute_UID (Node, &Id); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf (" _UID=%s", Id.Value); - } - - /* Get the _CID if present */ - - Status = AcpiUtExecute_CID (Node, &Cid); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value); - ACPI_FREE (Cid); - } - - AcpiOsPrintf ("\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbGetBusInfo - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Display info about system busses. - * - ******************************************************************************/ - -void -AcpiDbGetBusInfo ( - void) -{ - /* Search all nodes in namespace */ - - (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbBusWalk, NULL, NULL); + (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica-unix/debugger/dbdisply.c b/sys/contrib/dev/acpica-unix/debugger/dbdisply.c index 28b0f8f8ae..3cf89eda5b 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbdisply.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -612,7 +612,7 @@ AcpiDbDisplayResults ( for (i = 0; i < ResultCount; i++) { ObjDesc = Frame->Results.ObjDesc[Index]; - AcpiOsPrintf ("Result%d: ", i); + AcpiOsPrintf ("Result%u: ", i); AcpiDmDisplayInternalObject (ObjDesc, WalkState); if (Index == 0) { @@ -682,42 +682,52 @@ AcpiDbDisplayObjectType ( char *ObjectArg) { ACPI_HANDLE Handle; - ACPI_BUFFER Buffer; ACPI_DEVICE_INFO *Info; ACPI_STATUS Status; UINT32 i; Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (Handle, &Buffer); - if (ACPI_SUCCESS (Status)) + Status = AcpiGetObjectInfo (Handle, &Info); + if (ACPI_FAILURE (Status)) { - Info = Buffer.Pointer; - AcpiOsPrintf ( - "S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3], - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus); - - if (Info->Valid & ACPI_VALID_CID) - { - for (i = 0; i < Info->CompatibilityId.Count; i++) - { - AcpiOsPrintf ("CID #%d: %s\n", i, - Info->CompatibilityId.Id[i].Value); - } - } + AcpiOsPrintf ("Could not get object info, %s\n", + AcpiFormatException (Status)); + return; + } - ACPI_FREE (Info); + AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus, Info->Flags); + + AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3]); + + AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", + Info->LowestDstates[0], Info->LowestDstates[1], + Info->LowestDstates[2], Info->LowestDstates[3], + Info->LowestDstates[4]); + + if (Info->Valid & ACPI_VALID_HID) + { + AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); } - else + if (Info->Valid & ACPI_VALID_UID) { - AcpiOsPrintf ("%s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); } + if (Info->Valid & ACPI_VALID_CID) + { + for (i = 0; i < Info->CompatibleIdList.Count; i++) + { + AcpiOsPrintf ("CID %u: %s\n", i, + Info->CompatibleIdList.Ids[i].String); + } + } + + ACPI_FREE (Info); } @@ -806,6 +816,7 @@ AcpiDbDisplayGpes ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo; ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + char *GpeType; UINT32 GpeIndex; UINT32 Block = 0; UINT32 i; @@ -834,17 +845,25 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ("Could not convert name to pathname\n"); } - AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", - Block, GpeBlock, GpeBlock->Node, Buffer); + if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) + { + GpeType = "FADT-defined GPE block"; + } + else + { + GpeType = "GPE Block Device"; + } + + AcpiOsPrintf ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", + Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); AcpiOsPrintf (" Registers: %u (%u GPEs)\n", - GpeBlock->RegisterCount, - ACPI_MUL_8 (GpeBlock->RegisterCount)); + GpeBlock->RegisterCount, GpeBlock->GpeCount); - AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n", + AcpiOsPrintf (" GPE range: 0x%X to 0x%X on interrupt %u\n", GpeBlock->BlockBaseNumber, - GpeBlock->BlockBaseNumber + - (GpeBlock->RegisterCount * 8) -1); + GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), + GpeXruptInfo->InterruptNumber); AcpiOsPrintf ( " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", @@ -861,9 +880,12 @@ AcpiDbDisplayGpes ( GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; AcpiOsPrintf ( - " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", - i, GpeRegisterInfo->EnableForWake, + " Reg %u: (GPE %.2X-%.2X) RunEnable %2.2X WakeEnable %2.2X" + " Status %8.8X%8.8X Enable %8.8X%8.8X\n", + i, GpeRegisterInfo->BaseGpeNumber, + GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), GpeRegisterInfo->EnableForRun, + GpeRegisterInfo->EnableForWake, ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); @@ -874,18 +896,20 @@ AcpiDbDisplayGpes ( GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; - if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_NONE) { - /* This GPE is not used (no method or handler) */ + /* This GPE is not used (no method or handler), ignore it */ continue; } AcpiOsPrintf ( - " GPE %.3X: %p Flags %2.2X: ", - GpeBlock->BlockBaseNumber + GpeIndex, - GpeEventInfo, - GpeEventInfo->Flags); + " GPE %.2X: %p RunRefs %2.2X Flags %2.2X (", + GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo, + GpeEventInfo->RuntimeCount, GpeEventInfo->Flags); + + /* Decode the flags byte */ if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) { @@ -896,50 +920,28 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ("Edge, "); } - switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) { - case ACPI_GPE_TYPE_WAKE: - AcpiOsPrintf ("WakeOnly: "); - break; - case ACPI_GPE_TYPE_RUNTIME: - AcpiOsPrintf (" RunOnly: "); - break; - case ACPI_GPE_TYPE_WAKE_RUN: - AcpiOsPrintf (" WakeRun: "); - break; - default: - AcpiOsPrintf (" NotUsed: "); - break; - } - - if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED) - { - AcpiOsPrintf ("[Wake 1 "); + AcpiOsPrintf ("CanWake, "); } else { - AcpiOsPrintf ("[Wake 0 "); - } - - if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED) - { - AcpiOsPrintf ("Run 1], "); - } - else - { - AcpiOsPrintf ("Run 0], "); + AcpiOsPrintf ("RunOnly, "); } switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { - case ACPI_GPE_DISPATCH_NOT_USED: + case ACPI_GPE_DISPATCH_NONE: AcpiOsPrintf ("NotUsed"); break; + case ACPI_GPE_DISPATCH_METHOD: + AcpiOsPrintf ("Method"); + break; case ACPI_GPE_DISPATCH_HANDLER: AcpiOsPrintf ("Handler"); break; - case ACPI_GPE_DISPATCH_METHOD: - AcpiOsPrintf ("Method"); + case ACPI_GPE_DISPATCH_NOTIFY: + AcpiOsPrintf ("Notify"); break; default: AcpiOsPrintf ("UNKNOWN: %X", @@ -947,7 +949,7 @@ AcpiDbDisplayGpes ( break; } - AcpiOsPrintf ("\n"); + AcpiOsPrintf (")\n"); } } Block++; @@ -957,5 +959,140 @@ AcpiDbDisplayGpes ( } } -#endif /* ACPI_DEBUGGER */ +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHandlers + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display the currently installed global handlers + * + ******************************************************************************/ + +#define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : " +#define ACPI_HANDLER_NAME_STRING "%30s : " +#define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n" +#define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n" +/* All predefined Space IDs */ + +static ACPI_ADR_SPACE_TYPE SpaceIdList[] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_EC, + ACPI_ADR_SPACE_SMBUS, + ACPI_ADR_SPACE_CMOS, + ACPI_ADR_SPACE_PCI_BAR_TARGET, + ACPI_ADR_SPACE_IPMI, + ACPI_ADR_SPACE_DATA_TABLE, + ACPI_ADR_SPACE_FIXED_HARDWARE +}; + +/* Global handler information */ + +typedef struct acpi_handler_info +{ + void *Handler; + char *Name; + +} ACPI_HANDLER_INFO; + +ACPI_HANDLER_INFO HandlerList[] = +{ + {&AcpiGbl_SystemNotify.Handler, "System Notifications"}, + {&AcpiGbl_DeviceNotify.Handler, "Device Notifications"}, + {&AcpiGbl_TableHandler, "ACPI Table Events"}, + {&AcpiGbl_ExceptionHandler, "Control Method Exceptions"}, + {&AcpiGbl_InterfaceHandler, "OSI Invocations"} +}; + + +void +AcpiDbDisplayHandlers ( + void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_ADR_SPACE_TYPE SpaceId; + UINT32 i; + + + /* Operation region handlers */ + + AcpiOsPrintf ("\nOperation Region Handlers:\n"); + + ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); + if (ObjDesc) + { + for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++) + { + SpaceId = SpaceIdList[i]; + HandlerObj = ObjDesc->Device.Handler; + + AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, + AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId); + + while (HandlerObj) + { + if (i == HandlerObj->AddressSpace.SpaceId) + { + AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, + (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", + HandlerObj->AddressSpace.Handler); + goto FoundHandler; + } + + HandlerObj = HandlerObj->AddressSpace.Next; + } + + /* There is no handler for this SpaceId */ + + AcpiOsPrintf ("None\n"); + + FoundHandler:; + } + } + + /* Fixed event handlers */ + + AcpiOsPrintf ("\nFixed Event Handlers:\n"); + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i); + if (AcpiGbl_FixedEventHandlers[i].Handler) + { + AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", + AcpiGbl_FixedEventHandlers[i].Handler); + } + else + { + AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); + } + } + + /* Miscellaneous global handlers */ + + AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n"); + + for (i = 0; i < ACPI_ARRAY_LENGTH (HandlerList); i++) + { + AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, HandlerList[i].Name); + if (HandlerList[i].Handler) + { + AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", + HandlerList[i].Handler); + } + else + { + AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); + } + } +} + +#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica-unix/debugger/dbexec.c b/sys/contrib/dev/acpica-unix/debugger/dbexec.c index eb39b3749e..83b9f9b245 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbexec.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbexec.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -176,11 +176,13 @@ AcpiDbExecuteMethod ( ACPI_OBJECT_LIST ParamObjects; ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; ACPI_HANDLE Handle; - ACPI_BUFFER Buffer; UINT32 i; ACPI_DEVICE_INFO *ObjInfo; + ACPI_FUNCTION_TRACE (DbExecuteMethod); + + if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) { AcpiOsPrintf ("Warning: debug output is not enabled!\n"); @@ -191,29 +193,30 @@ AcpiDbExecuteMethod ( Status = AcpiGetHandle (NULL, Info->Pathname, &Handle); if (ACPI_FAILURE (Status)) { - return (Status); + return_ACPI_STATUS (Status); } /* Get the object info for number of method parameters */ - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiGetObjectInfo (Handle, &Buffer); + Status = AcpiGetObjectInfo (Handle, &ObjInfo); if (ACPI_FAILURE (Status)) { - return (Status); + return_ACPI_STATUS (Status); } ParamObjects.Pointer = NULL; ParamObjects.Count = 0; - ObjInfo = Buffer.Pointer; if (ObjInfo->Type == ACPI_TYPE_METHOD) { /* Are there arguments to the method? */ if (Info->Args && Info->Args[0]) { - for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++) + for (i = 0; Info->Args[i] && + (i < ACPI_METHOD_NUM_ARGS) && + (i < ObjInfo->ParamCount); + i++) { Params[i].Type = ACPI_TYPE_INTEGER; Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); @@ -246,7 +249,7 @@ AcpiDbExecuteMethod ( default: Params[i].Type = ACPI_TYPE_INTEGER; - Params[i].Integer.Value = i * (ACPI_INTEGER) 0x1000; + Params[i].Integer.Value = i * (UINT64) 0x1000; break; } } @@ -256,7 +259,7 @@ AcpiDbExecuteMethod ( } } - ACPI_FREE (Buffer.Pointer); + ACPI_FREE (ObjInfo); /* Prepare for a return object of arbitrary size */ @@ -272,7 +275,20 @@ AcpiDbExecuteMethod ( AcpiGbl_CmSingleStep = FALSE; AcpiGbl_MethodExecuting = FALSE; - return (Status); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "while executing %s from debugger", Info->Pathname)); + + if (Status == AE_BUFFER_OVERFLOW) + { + ACPI_ERROR ((AE_INFO, + "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", + ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length)); + } + } + + return_ACPI_STATUS (Status); } @@ -456,7 +472,7 @@ AcpiDbExecute ( if (*Name == '*') { (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL); + ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL); return; } else @@ -487,7 +503,7 @@ AcpiDbExecute ( * Allow any handlers in separate threads to complete. * (Such as Notify handlers invoked from AML executed above). */ - AcpiOsSleep ((ACPI_INTEGER) 10); + AcpiOsSleep ((UINT64) 10); #ifdef ACPI_DEBUG_OUTPUT @@ -570,14 +586,12 @@ AcpiDbMethodThread ( if (Info->InitArgs) { AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); - AcpiDbUInt32ToHexString (ACPI_TO_INTEGER (AcpiOsGetThreadId ()), - Info->IdOfThreadStr); + AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); } if (Info->Threads && (Info->NumCreated < Info->NumThreads)) { - Info->Threads[Info->NumCreated++] = - ACPI_TO_INTEGER (AcpiOsGetThreadId()); + Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId(); } LocalInfo = *Info; @@ -605,7 +619,7 @@ AcpiDbMethodThread ( #if 0 if ((i % 100) == 0) { - AcpiOsPrintf ("%d executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); + AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); } if (ReturnObj.Length) @@ -725,8 +739,8 @@ AcpiDbCreateExecutionThreads ( /* Array to store IDs of threads */ AcpiGbl_DbMethodInfo.NumThreads = NumThreads; - Size = 4 * AcpiGbl_DbMethodInfo.NumThreads; - AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size); + Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads; + AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size); if (AcpiGbl_DbMethodInfo.Threads == NULL) { AcpiOsPrintf ("No memory for thread IDs array\n"); diff --git a/sys/contrib/dev/acpica-unix/debugger/dbfileio.c b/sys/contrib/dev/acpica-unix/debugger/dbfileio.c index d52a72caa6..66ff961169 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbfileio.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -150,9 +150,6 @@ AcpiDbCheckTextModeCorruption ( UINT32 TableLength, UINT32 FileLength); -static ACPI_STATUS -AeLocalLoadTable ( - ACPI_TABLE_HEADER *TablePtr); #endif /******************************************************************************* @@ -292,7 +289,7 @@ AcpiDbCheckTextModeCorruption ( * meaning that we cannot simply replace CR/LF pairs with LFs. */ AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); - AcpiOsPrintf ("All LFs (%d) were changed to CR/LF pairs\n", Pairs); + AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); AcpiOsPrintf ("Table cannot be repaired!\n"); return (AE_BAD_VALUE); } @@ -424,7 +421,7 @@ AcpiDbReadTable ( { /* Now validate the checksum */ - Status = AcpiTbChecksum ((void *) *Table, + Status = AcpiTbVerifyChecksum ((void *) *Table, ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); if (Status == AE_BAD_CHECKSUM) diff --git a/sys/contrib/dev/acpica-unix/debugger/dbhistry.c b/sys/contrib/dev/acpica-unix/debugger/dbhistry.c index e8e8a76bf1..6b42b7b831 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbhistry.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -284,7 +284,7 @@ AcpiDbGetFromHistory ( } } - AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); + AcpiOsPrintf ("Invalid history number: %u\n", HistoryIndex); return (NULL); } diff --git a/sys/contrib/dev/acpica-unix/debugger/dbinput.c b/sys/contrib/dev/acpica-unix/debugger/dbinput.c index a64d547fdc..3ce99c748d 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbinput.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbinput.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -145,7 +145,7 @@ AcpiDbSingleThread ( static void AcpiDbDisplayHelp ( - char *HelpType); + void); /* @@ -176,6 +176,7 @@ enum AcpiExDebuggerCommands CMD_GO, CMD_GPE, CMD_GPES, + CMD_HANDLERS, CMD_HELP, CMD_HELP2, CMD_HISTORY, @@ -194,6 +195,7 @@ enum AcpiExDebuggerCommands CMD_NOTIFY, CMD_OBJECT, CMD_OPEN, + CMD_OSI, CMD_OWNER, CMD_PREDEFINED, CMD_PREFIX, @@ -242,6 +244,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"GO", 0}, {"GPE", 2}, {"GPES", 0}, + {"HANDLERS", 0}, {"HELP", 0}, {"?", 0}, {"HISTORY", 0}, @@ -260,6 +263,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"NOTIFY", 2}, {"OBJECT", 1}, {"OPEN", 1}, + {"OSI", 0}, {"OWNER", 1}, {"PREDEFINED", 0}, {"PREFIX", 0}, @@ -286,7 +290,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = * * FUNCTION: AcpiDbDisplayHelp * - * PARAMETERS: HelpType - Subcommand (optional) + * PARAMETERS: None * * RETURN: None * @@ -296,119 +300,80 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = static void AcpiDbDisplayHelp ( - char *HelpType) + void) { - AcpiUtStrupr (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 (" [STATISTICS] Statistical Information\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 ("Locks Current status of internal mutexes\n"); - AcpiOsPrintf ("Quit or Exit Exit this command\n"); - AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); - AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); - AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); - AcpiOsPrintf ("Unload [Instance] Unload an ACPI table\n"); - AcpiOsPrintf ("! Execute command from history buffer\n"); - AcpiOsPrintf ("!! Execute last command again\n"); - return; - - case 'S': - AcpiOsPrintf ("\nStats Subcommands\n\n"); - AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); - AcpiOsPrintf ("Memory Dump internal memory lists\n"); - AcpiOsPrintf ("Misc Namespace search and mutex stats\n"); - AcpiOsPrintf ("Objects Summary of namespace objects\n"); - AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n"); - AcpiOsPrintf ("Stack Display CPU stack usage\n"); - AcpiOsPrintf ("Tables Info about current ACPI table(s)\n"); - return; - - case 'N': - AcpiOsPrintf ("\nNamespace Access Commands\n\n"); - AcpiOsPrintf ("Businfo Display system bus info\n"); - AcpiOsPrintf ("Disassemble Disassemble a control method\n"); - AcpiOsPrintf ("Event Generate AcpiEvent (Fixed/GPE)\n"); - AcpiOsPrintf ("Find (? is wildcard) Find ACPI name(s) with wildcards\n"); - AcpiOsPrintf ("Gpe Simulate a GPE\n"); - AcpiOsPrintf ("Gpes Display info on all GPEs\n"); - AcpiOsPrintf ("Integrity Validate namespace integrity\n"); - AcpiOsPrintf ("Methods Display list of loaded control methods\n"); - AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); - AcpiOsPrintf ("Notify Send a notification on Object\n"); - AcpiOsPrintf ("Objects Display all objects of the given type\n"); - AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); - AcpiOsPrintf ("Predefined Check all predefined names\n"); - AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); - AcpiOsPrintf ("References Find all references to object at addr\n"); - AcpiOsPrintf ("Resources Get and display Device resources\n"); - AcpiOsPrintf ("Set N Set value for named integer\n"); - AcpiOsPrintf ("Sleep Simulate sleep/wake sequence\n"); - AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); - AcpiOsPrintf ("Type Display object type\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 ("Debug [Arguments] Single Step a control method\n"); - AcpiOsPrintf ("Execute [Arguments] Execute control method\n"); - AcpiOsPrintf ("Go Allow method to run to completion\n"); - AcpiOsPrintf ("Information Display info about the current method\n"); - AcpiOsPrintf ("Into Step into (not over) a method call\n"); - AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n"); - AcpiOsPrintf ("Locals Display method local variables\n"); - AcpiOsPrintf ("Results Display method result stack\n"); - AcpiOsPrintf ("Set <#> Set method data (Arguments/Locals)\n"); - AcpiOsPrintf ("Stop Terminate control method\n"); - AcpiOsPrintf ("Thread Spawn threads to execute method(s)\n"); - AcpiOsPrintf ("Trace Trace method execution\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: %s\n", HelpType); - return; - } + AcpiOsPrintf ("\nGeneral-Purpose Commands:\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 (" Handlers Info about global handlers\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 (" Locks Current status of internal mutexes\n"); + AcpiOsPrintf (" Osi [Install|Remove ] Display or modify global _OSI list\n"); + AcpiOsPrintf (" Quit or Exit Exit this command\n"); + AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n"); + AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf (" Allocations Display list of current memory allocations\n"); + AcpiOsPrintf (" Memory Dump internal memory lists\n"); + AcpiOsPrintf (" Misc Namespace search and mutex stats\n"); + AcpiOsPrintf (" Objects Summary of namespace objects\n"); + AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n"); + AcpiOsPrintf (" Stack Display CPU stack usage\n"); + AcpiOsPrintf (" Tables Info about current ACPI table(s)\n"); + AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n"); + AcpiOsPrintf (" Unload [Instance] Unload an ACPI table\n"); + AcpiOsPrintf (" ! Execute command from history buffer\n"); + AcpiOsPrintf (" !! Execute last command again\n"); + + AcpiOsPrintf ("\nNamespace Access Commands:\n"); + AcpiOsPrintf (" Businfo Display system bus info\n"); + AcpiOsPrintf (" Disassemble Disassemble a control method\n"); + AcpiOsPrintf (" Event Generate AcpiEvent (Fixed/GPE)\n"); + AcpiOsPrintf (" Find (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf (" Gpe Simulate a GPE\n"); + AcpiOsPrintf (" Gpes Display info on all GPEs\n"); + AcpiOsPrintf (" Integrity Validate namespace integrity\n"); + AcpiOsPrintf (" Methods Display list of loaded control methods\n"); + AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); + AcpiOsPrintf (" Notify Send a notification on Object\n"); + AcpiOsPrintf (" Objects Display all objects of the given type\n"); + AcpiOsPrintf (" Owner [Depth] Display loaded namespace by object owner\n"); + AcpiOsPrintf (" Predefined Check all predefined names\n"); + AcpiOsPrintf (" Prefix [] Set or Get current execution prefix\n"); + AcpiOsPrintf (" References Find all references to object at addr\n"); + AcpiOsPrintf (" Resources Get and display Device resources\n"); + AcpiOsPrintf (" Set N Set value for named integer\n"); + AcpiOsPrintf (" Sleep Simulate sleep/wake sequence\n"); + AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n"); + AcpiOsPrintf (" Type Display object type\n"); + + AcpiOsPrintf ("\nControl Method Execution Commands:\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 (" Debug [Arguments] Single Step a control method\n"); + AcpiOsPrintf (" Execute [Arguments] Execute control method\n"); + AcpiOsPrintf (" Go Allow method to run to completion\n"); + AcpiOsPrintf (" Information Display info about the current method\n"); + AcpiOsPrintf (" Into Step into (not over) a method call\n"); + AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n"); + AcpiOsPrintf (" Locals Display method local variables\n"); + AcpiOsPrintf (" Results Display method result stack\n"); + AcpiOsPrintf (" Set <#> Set method data (Arguments/Locals)\n"); + AcpiOsPrintf (" Stop Terminate control method\n"); + AcpiOsPrintf (" Thread Spawn threads to execute method(s)\n"); + AcpiOsPrintf (" Trace Trace method execution\n"); + AcpiOsPrintf (" Tree Display control method calling tree\n"); + AcpiOsPrintf (" Single step next AML opcode (over calls)\n"); + + AcpiOsPrintf ("\nFile I/O Commands:\n"); + AcpiOsPrintf (" Close Close debug output file\n"); + AcpiOsPrintf (" Load Load ACPI table from a file\n"); + AcpiOsPrintf (" Open Open a file for debug output\n"); } @@ -455,13 +420,30 @@ AcpiDbGetNextToken ( } } - Start = String; + if (*String == '"') + { + /* This is a quoted string, scan until closing quote */ + + String++; + Start = String; - /* Find end of token */ + /* Find end of token */ - while (*String && (*String != ' ')) + while (*String && (*String != '"')) + { + String++; + } + } + else { - String++; + Start = String; + + /* Find end of token */ + + while (*String && (*String != ' ')) + { + String++; + } } if (!(*String)) @@ -613,7 +595,7 @@ AcpiDbCommandDispatch ( if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) { - AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", + AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n", ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); @@ -644,7 +626,7 @@ AcpiDbCommandDispatch ( break; case CMD_BATCH: - AcpiDbBatchExecute (); + AcpiDbBatchExecute (AcpiGbl_DbArgs[1]); break; case CMD_BREAKPOINT: @@ -710,9 +692,13 @@ AcpiDbCommandDispatch ( AcpiDbDisplayGpes (); break; + case CMD_HANDLERS: + AcpiDbDisplayHandlers (); + break; + case CMD_HELP: case CMD_HELP2: - AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]); + AcpiDbDisplayHelp (); break; case CMD_HISTORY: @@ -820,6 +806,10 @@ AcpiDbCommandDispatch ( AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); break; + case CMD_OSI: + AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); + break; + case CMD_OWNER: AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; diff --git a/sys/contrib/dev/acpica-unix/debugger/dbmethod.c b/sys/contrib/dev/acpica-unix/debugger/dbmethod.c new file mode 100644 index 0000000000..110a7baca8 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/debugger/dbmethod.c @@ -0,0 +1,597 @@ +/******************************************************************************* + * + * Module Name: dbmethod - Debug commands for control methods + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acdebug.h" +#include "acdisasm.h" +#include "acparser.h" + + +#ifdef ACPI_DEBUGGER + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("dbmethod") + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbWalkForExecute ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodBreakpoint + * + * PARAMETERS: Location - AML offset of breakpoint + * WalkState - Current walk info + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodBreakpoint ( + char *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 Address; + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + /* Get and verify the breakpoint address */ + + Address = ACPI_STRTOUL (Location, NULL, 16); + if (Address <= Op->Common.AmlOffset) + { + AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", + Address, Op->Common.AmlOffset); + } + + /* Save breakpoint in current walk */ + + WalkState->UserBreakpoint = Address; + AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodCallBreakpoint + * + * PARAMETERS: Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op) +{ + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + AcpiGbl_StepToNextCall = TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodData + * + * PARAMETERS: TypeArg - L for local, A for argument + * IndexArg - which one + * ValueArg - Value to set. + * + * RETURN: None + * + * DESCRIPTION: Set a local or argument for the running control method. + * NOTE: only object supported is Number. + * + ******************************************************************************/ + +void +AcpiDbSetMethodData ( + char *TypeArg, + char *IndexArg, + char *ValueArg) +{ + char Type; + UINT32 Index; + UINT32 Value; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Validate TypeArg */ + + AcpiUtStrupr (TypeArg); + Type = TypeArg[0]; + if ((Type != 'L') && + (Type != 'A') && + (Type != 'N')) + { + AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); + return; + } + + Value = ACPI_STRTOUL (ValueArg, NULL, 16); + + if (Type == 'N') + { + Node = AcpiDbConvertToNode (IndexArg); + if (Node->Type != ACPI_TYPE_INTEGER) + { + AcpiOsPrintf ("Can only set Integer nodes\n"); + return; + } + ObjDesc = Node->Object; + ObjDesc->Integer.Value = Value; + return; + } + + /* Get the index and value */ + + Index = ACPI_STRTOUL (IndexArg, NULL, 16); + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + /* Create and initialize the new object */ + + ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value); + if (!ObjDesc) + { + AcpiOsPrintf ("Could not create an internal object\n"); + return; + } + + /* Store the new object into the target */ + + switch (Type) + { + case 'A': + + /* Set a method argument */ + + if (Index > ACPI_METHOD_MAX_ARG) + { + AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); + goto Cleanup; + } + + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, + WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc = WalkState->Arguments[Index].Object; + + AcpiOsPrintf ("Arg%u: ", Index); + AcpiDmDisplayInternalObject (ObjDesc, WalkState); + break; + + case 'L': + + /* Set a method local */ + + if (Index > ACPI_METHOD_MAX_LOCAL) + { + AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); + goto Cleanup; + } + + Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, + WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc = WalkState->LocalVariables[Index].Object; + + AcpiOsPrintf ("Local%u: ", Index); + AcpiDmDisplayInternalObject (ObjDesc, WalkState); + break; + + default: + break; + } + +Cleanup: + AcpiUtRemoveReference (ObjDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisassembleAml + * + * PARAMETERS: Statements - Number of statements to disassemble + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +void +AcpiDbDisassembleAml ( + char *Statements, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 NumStatements = 8; + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + if (Statements) + { + NumStatements = ACPI_STRTOUL (Statements, NULL, 0); + } + + AcpiDmDisassemble (NULL, Op, NumStatements); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisassembleMethod + * + * PARAMETERS: Name - Name of control method + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Method; + + + Method = AcpiDbConvertToNode (Name); + if (!Method) + { + return (AE_BAD_PARAMETER); + } + + ObjDesc = Method->Object; + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); + if (!WalkState) + { + return (AE_NO_MEMORY); + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Parse the AML */ + + WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; + Status = AcpiPsParseAml (WalkState); + + AcpiDmDisassemble (NULL, Op, 0); + AcpiPsDeleteParseTree (Op); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForExecute + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Batch execution module. Currently only executes predefined + * ACPI names. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForExecute ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context; + ACPI_BUFFER ReturnObj; + ACPI_STATUS Status; + char *Pathname; + UINT32 i; + ACPI_DEVICE_INFO *ObjInfo; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; + const ACPI_PREDEFINED_INFO *Predefined; + + + Predefined = AcpiNsCheckForPredefinedName (Node); + if (!Predefined) + { + return (AE_OK); + } + + if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) + { + return (AE_OK); + } + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); + } + + /* Get the object info for number of method parameters */ + + Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParamObjects.Pointer = NULL; + ParamObjects.Count = 0; + + if (ObjInfo->Type == ACPI_TYPE_METHOD) + { + /* Setup default parameters */ + + for (i = 0; i < ObjInfo->ParamCount; i++) + { + Params[i].Type = ACPI_TYPE_INTEGER; + Params[i].Integer.Value = 1; + } + + ParamObjects.Pointer = Params; + ParamObjects.Count = ObjInfo->ParamCount; + } + + ACPI_FREE (ObjInfo); + ReturnObj.Pointer = NULL; + ReturnObj.Length = ACPI_ALLOCATE_BUFFER; + + /* Do the actual method execution */ + + AcpiGbl_MethodExecuting = TRUE; + + Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj); + + AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status)); + AcpiGbl_MethodExecuting = FALSE; + ACPI_FREE (Pathname); + + /* Ignore status from method execution */ + + Status = AE_OK; + + /* Update count, check if we have executed enough methods */ + + Info->Count++; + if (Info->Count >= Info->MaxCount) + { + Status = AE_CTRL_TERMINATE; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBatchExecute + * + * PARAMETERS: CountArg - Max number of methods to execute + * + * RETURN: None + * + * DESCRIPTION: Namespace batch execution. Execute predefined names in the + * namespace, up to the max count, if specified. + * + ******************************************************************************/ + +void +AcpiDbBatchExecute ( + char *CountArg) +{ + ACPI_EXECUTE_WALK Info; + + + Info.Count = 0; + Info.MaxCount = ACPI_UINT32_MAX; + + if (CountArg) + { + Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0); + } + + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForExecute, NULL, (void *) &Info, NULL); + + AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count); +} + +#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica-unix/debugger/dbnames.c b/sys/contrib/dev/acpica-unix/debugger/dbnames.c new file mode 100644 index 0000000000..b1d0712db3 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/debugger/dbnames.c @@ -0,0 +1,1006 @@ +/******************************************************************************* + * + * Module Name: dbnames - Debugger commands for the acpi namespace + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "accommon.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#ifdef ACPI_DEBUGGER + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("dbnames") + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForPredefinedNames ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbIntegrityWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbBusWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +/* + * Arguments for the Objects command + * These object types map directly to the ACPI_TYPES + */ +static ARGUMENT_INFO AcpiDbObjectTypes [] = +{ + {"ANY"}, + {"INTEGERS"}, + {"STRINGS"}, + {"BUFFERS"}, + {"PACKAGES"}, + {"FIELDS"}, + {"DEVICES"}, + {"EVENTS"}, + {"METHODS"}, + {"MUTEXES"}, + {"REGIONS"}, + {"POWERRESOURCES"}, + {"PROCESSORS"}, + {"THERMALZONES"}, + {"BUFFERFIELDS"}, + {"DDBHANDLES"}, + {"DEBUG"}, + {"REGIONFIELDS"}, + {"BANKFIELDS"}, + {"INDEXFIELDS"}, + {"REFERENCES"}, + {"ALIAS"}, + {NULL} /* Must be null terminated */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetScope + * + * PARAMETERS: Name - New scope path + * + * RETURN: Status + * + * DESCRIPTION: Set the "current scope" as maintained by this utility. + * The scope is used as a prefix to ACPI paths. + * + ******************************************************************************/ + +void +AcpiDbSetScope ( + char *Name) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + if (!Name || Name[0] == 0) + { + AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); + return; + } + + AcpiDbPrepNamestring (Name); + + if (Name[0] == '\\') + { + /* Validate new scope from the root */ + + Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, + &Node); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); + ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + } + else + { + /* Validate new scope relative to old scope */ + + Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, + &Node); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); + ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + } + + AcpiGbl_DbScopeNode = Node; + AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); + return; + +ErrorExit: + + AcpiOsPrintf ("Could not attach scope: %s, %s\n", + Name, AcpiFormatException (Status)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpNamespace + * + * PARAMETERS: StartArg - Node to begin namespace dump + * DepthArg - Maximum tree depth to be dumped + * + * RETURN: None + * + * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed + * with type and other information. + * + ******************************************************************************/ + +void +AcpiDbDumpNamespace ( + char *StartArg, + char *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + + + /* No argument given, just start at the root and dump entire namespace */ + + if (StartArg) + { + SubtreeEntry = AcpiDbConvertToNode (StartArg); + if (!SubtreeEntry) + { + return; + } + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + } + } + + AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", + ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, + ACPI_OWNER_ID_MAX, SubtreeEntry); + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpNamespaceByOwner + * + * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed + * DepthArg - Maximum tree depth to be dumped + * + * RETURN: None + * + * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. + * + ******************************************************************************/ + +void +AcpiDbDumpNamespaceByOwner ( + char *OwnerArg, + char *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + ACPI_OWNER_ID OwnerId; + + + OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); + } + + AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, + SubtreeEntry); + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkAndMatchName + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Find a particular name/names within the namespace. Wildcards + * are supported -- '?' matches any character. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + char *RequestedName = (char *) Context; + UINT32 i; + ACPI_BUFFER Buffer; + ACPI_WALK_INFO Info; + + + /* Check for a name match */ + + for (i = 0; i < 4; i++) + { + /* Wildcard support */ + + if ((RequestedName[i] != '?') && + (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) + { + /* No match, just exit */ + + return (AE_OK); + } + } + + /* Get the full pathname to this object */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + } + else + { + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DebugLevel = ACPI_UINT32_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; + + AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); + (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); + ACPI_FREE (Buffer.Pointer); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbFindNameInNamespace + * + * PARAMETERS: NameArg - The 4-character ACPI name to find. + * wildcards are supported. + * + * RETURN: None + * + * DESCRIPTION: Search the namespace for a given name (with wildcards) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + char *NameArg) +{ + char AcpiName[5] = "____"; + char *AcpiNamePtr = AcpiName; + + + if (ACPI_STRLEN (NameArg) > 4) + { + AcpiOsPrintf ("Name must be no longer than 4 characters\n"); + return (AE_OK); + } + + /* Pad out name with underscores as necessary to create a 4-char name */ + + AcpiUtStrupr (NameArg); + while (*NameArg) + { + *AcpiNamePtr = *NameArg; + AcpiNamePtr++; + NameArg++; + } + + /* Walk the namespace from the root */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); + + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForPredefinedNames + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Detect and display predefined ACPI names (names that start with + * an underscore) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForPredefinedNames ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + UINT32 *Count = (UINT32 *) Context; + const ACPI_PREDEFINED_INFO *Predefined; + const ACPI_PREDEFINED_INFO *Package = NULL; + char *Pathname; + + + Predefined = AcpiNsCheckForPredefinedName (Node); + if (!Predefined) + { + return (AE_OK); + } + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); + } + + /* If method returns a package, the info is in the next table entry */ + + if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE) + { + Package = Predefined + 1; + } + + AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname, + Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes); + + if (Package) + { + AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X", + Package->RetInfo.Type, Package->RetInfo.ObjectType1, + Package->RetInfo.Count1); + } + + AcpiOsPrintf("\n"); + + AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined); + ACPI_FREE (Pathname); + (*Count)++; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCheckPredefinedNames + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Validate all predefined names in the namespace + * + ******************************************************************************/ + +void +AcpiDbCheckPredefinedNames ( + void) +{ + UINT32 Count = 0; + + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL); + + AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForSpecificObjects + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_BUFFER Buffer; + ACPI_STATUS Status; + + + Info->Count++; + + /* Get and display the full pathname to this object */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); + + /* Dump short info about the object */ + + (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayObjects + * + * PARAMETERS: ObjTypeArg - Type of object to display + * DisplayCountArg - Max depth to display + * + * RETURN: None + * + * DESCRIPTION: Display objects in the namespace of the requested type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayObjects ( + char *ObjTypeArg, + char *DisplayCountArg) +{ + ACPI_WALK_INFO Info; + ACPI_OBJECT_TYPE Type; + + + /* Get the object type */ + + Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); + if (Type == ACPI_TYPE_NOT_FOUND) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + + AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ( + "Objects of type [%s] defined in the current ACPI Namespace:\n", + AcpiUtGetTypeName (Type)); + + AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + + Info.Count = 0; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DebugLevel = ACPI_UINT32_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; + + /* Walk the namespace from the root */ + + (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); + + AcpiOsPrintf ( + "\nFound %u objects of type [%s] in the current ACPI Namespace\n", + Info.Count, AcpiUtGetTypeName (Type)); + + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbIntegrityWalk + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Examine one NS node for valid values. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbIntegrityWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *Object; + BOOLEAN Alias = TRUE; + + + Info->Nodes++; + + /* Verify the NS node, and dereference aliases */ + + while (Alias) + { + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n", + Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node), + ACPI_DESC_TYPE_NAMED); + return (AE_OK); + } + + if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) || + (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + Node = (ACPI_NAMESPACE_NODE *) Node->Object; + } + else + { + Alias = FALSE; + } + } + + if (Node->Type > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", + Node, Node->Type); + return (AE_OK); + } + + if (!AcpiUtValidAcpiName (Node->Name.Integer)) + { + AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); + return (AE_OK); + } + + Object = AcpiNsGetAttachedObject (Node); + if (Object) + { + Info->Objects++; + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", + Object, AcpiUtGetDescriptorName (Object)); + } + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCheckIntegrity + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Check entire namespace for data structure integrity + * + ******************************************************************************/ + +void +AcpiDbCheckIntegrity ( + void) +{ + ACPI_INTEGRITY_INFO Info = {0,0}; + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); + + AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", + Info.Nodes, Info.Objects); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForReferences + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Check if this namespace object refers to the target object + * that is passed in as the context value. + * + * Note: Currently doesn't check subobjects within the Node's object + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + + /* Check for match against the namespace node itself */ + + if (Node == (void *) ObjDesc) + { + AcpiOsPrintf ("Object is a Node [%4.4s]\n", + AcpiUtGetNodeName (Node)); + } + + /* Check for match against the object attached to the node */ + + if (AcpiNsGetAttachedObject (Node) == ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", + Node, AcpiUtGetNodeName (Node)); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbFindReferences + * + * PARAMETERS: ObjectArg - String with hex value of the object + * + * RETURN: None + * + * DESCRIPTION: Search namespace for all references to the input object + * + ******************************************************************************/ + +void +AcpiDbFindReferences ( + char *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Convert string to object pointer */ + + ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); + + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBusWalk + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display info about device objects that have a corresponding + * _PRT method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbBusWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_NAMESPACE_NODE *TempNode; + ACPI_DEVICE_INFO *Info; + UINT32 i; + + + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR)) + { + return (AE_OK); + } + + /* Exit if there is no _PRT under this device */ + + Status = AcpiGetHandle (Node, METHOD_NAME__PRT, + ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); + if (ACPI_FAILURE (Status)) + { + return (AE_OK); + } + + /* Get the full path to this device object */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + Status = AcpiGetObjectInfo (ObjHandle, &Info); + if (ACPI_FAILURE (Status)) + { + return (AE_OK); + } + + /* Display the full path */ + + AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); + ACPI_FREE (Buffer.Pointer); + + if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) + { + AcpiOsPrintf (" - Is PCI Root Bridge"); + } + AcpiOsPrintf ("\n"); + + /* _PRT info */ + + AcpiOsPrintf ("_PRT: %p\n", TempNode); + + /* Dump _ADR, _HID, _UID, _CID */ + + if (Info->Valid & ACPI_VALID_ADR) + { + AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); + } + else + { + AcpiOsPrintf ("_ADR: \n"); + } + + if (Info->Valid & ACPI_VALID_HID) + { + AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); + } + else + { + AcpiOsPrintf ("_HID: \n"); + } + + if (Info->Valid & ACPI_VALID_UID) + { + AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); + } + else + { + AcpiOsPrintf ("_UID: \n"); + } + + if (Info->Valid & ACPI_VALID_CID) + { + for (i = 0; i < Info->CompatibleIdList.Count; i++) + { + AcpiOsPrintf ("_CID: %s\n", + Info->CompatibleIdList.Ids[i].String); + } + } + else + { + AcpiOsPrintf ("_CID: \n"); + } + + ACPI_FREE (Info); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetBusInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display info about system busses. + * + ******************************************************************************/ + +void +AcpiDbGetBusInfo ( + void) +{ + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbBusWalk, NULL, NULL, NULL); +} + +#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica-unix/debugger/dbstats.c b/sys/contrib/dev/acpica-unix/debugger/dbstats.c index f2f2f78f6a..5c1ce99c0c 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbstats.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbstats.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -446,7 +446,7 @@ AcpiDbCountNamespaceObjects ( } (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL); + ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL, NULL); } diff --git a/sys/contrib/dev/acpica-unix/debugger/dbutils.c b/sys/contrib/dev/acpica-unix/debugger/dbutils.c index b49726369b..e6cba84051 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbutils.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -275,6 +275,10 @@ AcpiDbDumpExternalObject ( AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); if (ObjDesc->Buffer.Length) { + if (ObjDesc->Buffer.Length > 16) + { + AcpiOsPrintf ("\n"); + } AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); } @@ -287,7 +291,7 @@ AcpiDbDumpExternalObject ( case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("[Package] Contains %d Elements:\n", + AcpiOsPrintf ("[Package] Contains %u Elements:\n", ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) diff --git a/sys/contrib/dev/acpica-unix/debugger/dbxface.c b/sys/contrib/dev/acpica-unix/debugger/dbxface.c index f3f7a44746..2d156e63bc 100644 --- a/sys/contrib/dev/acpica-unix/debugger/dbxface.c +++ b/sys/contrib/dev/acpica-unix/debugger/dbxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmbuffer.c b/sys/contrib/dev/acpica-unix/disassembler/dmbuffer.c index 5a4d1742f3..239978137b 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmbuffer.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmbuffer.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmnames.c b/sys/contrib/dev/acpica-unix/disassembler/dmnames.c index b09d3d35f5..a00aff1647 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmnames.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmobject.c b/sys/contrib/dev/acpica-unix/disassembler/dmobject.c index 0f569922ad..1aa7215b75 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmobject.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -289,7 +289,7 @@ AcpiDmDecodeInternalObject ( case ACPI_TYPE_STRING: - AcpiOsPrintf ("(%d) \"%.24s", + AcpiOsPrintf ("(%u) \"%.24s", ObjDesc->String.Length, ObjDesc->String.Pointer); if (ObjDesc->String.Length > 24) @@ -305,7 +305,7 @@ AcpiDmDecodeInternalObject ( case ACPI_TYPE_BUFFER: - AcpiOsPrintf ("(%d)", ObjDesc->Buffer.Length); + AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length); for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++) { AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]); @@ -651,7 +651,7 @@ AcpiDmDisplayArguments ( for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { ObjDesc = WalkState->Arguments[i].Object; - AcpiOsPrintf (" Arg%d: ", i); + AcpiOsPrintf (" Arg%u: ", i); AcpiDmDisplayInternalObject (ObjDesc, WalkState); } } diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmopcode.c b/sys/contrib/dev/acpica-unix/disassembler/dmopcode.c index 931ef6c0db..652c8a64a0 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmopcode.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmopcode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -163,7 +163,7 @@ AcpiDmMethodFlags ( /* 1) Method argument count */ - AcpiOsPrintf (", %d, ", Args); + AcpiOsPrintf (", %u, ", Args); /* 2) Serialize rule */ @@ -178,7 +178,7 @@ AcpiDmMethodFlags ( if (Flags & 0xF0) { - AcpiOsPrintf (", %d", Flags >> 4); + AcpiOsPrintf (", %u", Flags >> 4); } } @@ -473,8 +473,8 @@ AcpiDmDisassembleOneOp ( case AML_QWORD_OP: - AcpiOsPrintf ("0x%8.8X%8.8X", Op->Common.Value.Integer64.Hi, - Op->Common.Value.Integer64.Lo); + AcpiOsPrintf ("0x%8.8X%8.8X", + ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); break; @@ -550,7 +550,7 @@ AcpiDmDisassembleOneOp ( case AML_INT_NAMEDFIELD_OP: Length = AcpiDmDumpName (Op->Named.Name); - AcpiOsPrintf (",%*.s %d", (int) (5 - Length), " ", + AcpiOsPrintf (",%*.s %u", (unsigned) (5 - Length), " ", (UINT32) Op->Common.Value.Integer); AcpiDmCommaIfFieldMember (Op); @@ -571,7 +571,7 @@ AcpiDmDisassembleOneOp ( } else { - AcpiOsPrintf (" , %d", Offset); + AcpiOsPrintf (" , %u", Offset); } AcpiDmCommaIfFieldMember (Op); diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmresrc.c b/sys/contrib/dev/acpica-unix/disassembler/dmresrc.c index f0fc4b1bd6..93a6c05505 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmresrc.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmresrc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -290,7 +290,7 @@ AcpiDmBitList ( AcpiOsPrintf (","); } Previous = TRUE; - AcpiOsPrintf ("%d", i); + AcpiOsPrintf ("%u", i); } Mask >>= 1; diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmresrcl.c b/sys/contrib/dev/acpica-unix/disassembler/dmresrcl.c index b1b86db2f3..d266c5793b 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmresrcl.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmresrcl.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmresrcs.c b/sys/contrib/dev/acpica-unix/disassembler/dmresrcs.c index 50898527fb..2bb1c91f87 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmresrcs.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmresrcs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmutils.c b/sys/contrib/dev/acpica-unix/disassembler/dmutils.c index 75794b9f70..b64b8fb000 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmutils.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -129,9 +129,6 @@ ACPI_MODULE_NAME ("dmutils") -ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList = NULL; - - /* Data used in keeping track of fields */ #if 0 const char *AcpiGbl_FENames[] = @@ -202,121 +199,6 @@ const char *AcpiGbl_IrqDecode[] = }; -#ifdef ACPI_ASL_COMPILER -/******************************************************************************* - * - * FUNCTION: AcpiDmAddToExternalList - * - * PARAMETERS: Path - Internal (AML) path to the object - * - * RETURN: None - * - * DESCRIPTION: Insert a new path into the list of Externals which will in - * turn be emitted as an External() declaration in the disassembled - * output. - * - ******************************************************************************/ - -void -AcpiDmAddToExternalList ( - char *Path, - UINT8 Type, - UINT32 Value) -{ - char *ExternalPath; - ACPI_EXTERNAL_LIST *NewExternal; - ACPI_EXTERNAL_LIST *NextExternal; - ACPI_EXTERNAL_LIST *PrevExternal = NULL; - ACPI_STATUS Status; - - - if (!Path) - { - return; - } - - /* Externalize the ACPI path */ - - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, - NULL, &ExternalPath); - if (ACPI_FAILURE (Status)) - { - return; - } - - /* Ensure that we don't have duplicate externals */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - /* Allow upgrade of type from ANY */ - - if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) - { - /* Duplicate method, check that the Value (ArgCount) is the same */ - - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value)) - { - ACPI_ERROR ((AE_INFO, "Argument count mismatch for method %s %d %d", - NextExternal->Path, NextExternal->Value, Value)); - } - if (NextExternal->Type == ACPI_TYPE_ANY) - { - NextExternal->Type = Type; - NextExternal->Value = Value; - } - ACPI_FREE (ExternalPath); - return; - } - NextExternal = NextExternal->Next; - } - - /* Allocate and init a new External() descriptor */ - - NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); - NewExternal->InternalPath = Path; - NewExternal->Path = ExternalPath; - NewExternal->Type = Type; - NewExternal->Value = Value; - NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); - - /* Link the new descriptor into the global list, ordered by string length */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (NewExternal->Length <= NextExternal->Length) - { - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } - - NewExternal->Next = NextExternal; - return; - } - - PrevExternal = NextExternal; - NextExternal = NextExternal->Next; - } - - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } -} -#endif - - /******************************************************************************* * * FUNCTION: AcpiDmDecodeAttribute diff --git a/sys/contrib/dev/acpica-unix/disassembler/dmwalk.c b/sys/contrib/dev/acpica-unix/disassembler/dmwalk.c index 156e2dd5b1..86aee3d1bb 100644 --- a/sys/contrib/dev/acpica-unix/disassembler/dmwalk.c +++ b/sys/contrib/dev/acpica-unix/disassembler/dmwalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -130,6 +130,17 @@ #define DB_FULL_OP_INFO "[%4.4s] @%5.5X #%4.4X: " +/* Stub for non-compiler code */ + +#ifndef ACPI_ASL_COMPILER +void +AcpiDmEmitExternals ( + void) +{ + return; +} +#endif + /* Local prototypes */ static ACPI_STATUS @@ -148,69 +159,6 @@ static UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op); -static const char * -AcpiDmGetObjectTypeName ( - ACPI_OBJECT_TYPE Type); - -/* - * This table maps ACPI_OBJECT_TYPEs to the corresponding ASL - * ObjectTypeKeyword. Used to generate typed external declarations - */ -static const char *AcpiGbl_DmTypeNames[] = -{ - /* 00 */ "", /* Type ANY */ - /* 01 */ ", IntObj", - /* 02 */ ", StrObj", - /* 03 */ ", BuffObj", - /* 04 */ ", PkgObj", - /* 05 */ ", FieldUnitObj", - /* 06 */ ", DeviceObj", - /* 07 */ ", EventObj", - /* 08 */ ", MethodObj", - /* 09 */ ", MutexObj", - /* 10 */ ", OpRegionObj", - /* 11 */ ", PowerResObj", - /* 12 */ ", ProcessorObj", - /* 13 */ ", ThermalZoneObj", - /* 14 */ ", BuffFieldObj", - /* 15 */ ", DDBHandleObj", - /* 16 */ "", /* Debug object */ - /* 17 */ ", FieldUnitObj", - /* 18 */ ", FieldUnitObj", - /* 19 */ ", FieldUnitObj" -}; - - -/******************************************************************************* - * - * FUNCTION: AcpiDmGetObjectTypeName - * - * PARAMETERS: Type - An ACPI_OBJECT_TYPE - * - * RETURN: Pointer to a string - * - * DESCRIPTION: Map an object type to the ASL object type string. - * - ******************************************************************************/ - -static const char * -AcpiDmGetObjectTypeName ( - ACPI_OBJECT_TYPE Type) -{ - - if (Type == ACPI_TYPE_LOCAL_SCOPE) - { - Type = ACPI_TYPE_DEVICE; - } - - else if (Type > ACPI_TYPE_LOCAL_INDEX_FIELD) - { - return (""); - } - - return (AcpiGbl_DmTypeNames[Type]); -} - /******************************************************************************* * @@ -522,7 +470,6 @@ AcpiDmDescendingOp ( const ACPI_OPCODE_INFO *OpInfo; UINT32 Name; ACPI_PARSE_OBJECT *NextOp; - ACPI_EXTERNAL_LIST *NextExternal; if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) @@ -554,35 +501,7 @@ AcpiDmDescendingOp ( /* Emit all External() declarations here */ - if (AcpiGbl_ExternalList) - { - /* - * Walk the list of externals (unresolved references) - * found during parsing - */ - while (AcpiGbl_ExternalList) - { - AcpiOsPrintf (" External (%s%s", - AcpiGbl_ExternalList->Path, - AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type)); - - if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) - { - AcpiOsPrintf (") // %d Arguments\n", AcpiGbl_ExternalList->Value); - } - else - { - AcpiOsPrintf (")\n"); - } - - NextExternal = AcpiGbl_ExternalList->Next; - ACPI_FREE (AcpiGbl_ExternalList->Path); - ACPI_FREE (AcpiGbl_ExternalList); - AcpiGbl_ExternalList = NextExternal; - } - AcpiOsPrintf ("\n"); - } - + AcpiDmEmitExternals (); return (AE_OK); } } diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsargs.c b/sys/contrib/dev/acpica-unix/dispatcher/dsargs.c new file mode 100644 index 0000000000..44cc41b339 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsargs.c @@ -0,0 +1,502 @@ +/****************************************************************************** + * + * Module Name: dsargs - Support for execution of dynamic arguments for static + * objects (regions, fields, buffer fields, etc.) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSARGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsargs") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecuteArguments + * + * PARAMETERS: Node - Object NS node + * ScopeNode - Parent NS node + * AmlLength - Length of executable AML + * AmlStart - Pointer to the AML + * + * RETURN: Status. + * + * DESCRIPTION: Late (deferred) execution of region or field arguments + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsExecuteArguments); + + + /* Allocate a new parser op to be the root of the parsed tree */ + + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this parse as a deferred opcode */ + + WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; + WalkState->DeferredNode = Node; + + /* Pass1: Parse the entire declaration */ + + Status = AcpiPsParseAml (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Get and init the Op created above */ + + Op->Common.Node = Node; + AcpiPsDeleteParseTree (Op); + + /* Evaluate the deferred arguments */ + + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the opcode and arguments */ + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_EXECUTE); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this execution as a deferred opcode */ + + WalkState->DeferredNode = Node; + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferFieldArguments + * + * PARAMETERS: ObjDesc - A valid BufferField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BufferField Buffer and Index. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BufferField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BufferField.Node; + + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, + Node, NULL)); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node->Parent, + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBankFieldArguments + * + * PARAMETERS: ObjDesc - A valid BankField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BankField BankValue. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BankField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BankField.Node; + + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, + Node, NULL)); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node->Parent, + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferArguments + * + * PARAMETERS: ObjDesc - A valid Buffer object + * + * RETURN: Status. + * + * DESCRIPTION: Get Buffer length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Buffer node */ + + Node = ObjDesc->Buffer.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to namespace node in buffer object %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetPackageArguments + * + * PARAMETERS: ObjDesc - A valid Package object + * + * RETURN: Status. + * + * DESCRIPTION: Get Package length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Package node */ + + Node = ObjDesc->Package.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to namespace node in package %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetRegionArguments + * + * PARAMETERS: ObjDesc - A valid region object + * + * RETURN: Status. + * + * DESCRIPTION: Get region address and length. This implements the late + * evaluation of these region attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ExtraDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); + + + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + if (!ExtraDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the Region node */ + + Node = ObjDesc->Region.Node; + + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", + AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); + + /* Execute the argument AML */ + + Status = AcpiDsExecuteArguments (Node, Node->Parent, + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dscontrol.c b/sys/contrib/dev/acpica-unix/dispatcher/dscontrol.c new file mode 100644 index 0000000000..41435e072c --- /dev/null +++ b/sys/contrib/dev/acpica-unix/dispatcher/dscontrol.c @@ -0,0 +1,496 @@ +/****************************************************************************** + * + * Module Name: dscontrol - Support for execution control opcodes - + * if/else/while/return + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSCONTROL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dscontrol") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecBeginControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecBeginControlOp); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", + Op, Op->Common.AmlOpcode, WalkState)); + + switch (Op->Common.AmlOpcode) + { + case AML_WHILE_OP: + + /* + * If this is an additional iteration of a while loop, continue. + * There is no need to allocate a new control state. + */ + if (WalkState->ControlState) + { + if (WalkState->ControlState->Control.AmlPredicateStart == + (WalkState->ParserState.Aml - 1)) + { + /* Reset the state to start-of-loop */ + + WalkState->ControlState->Common.State = + ACPI_CONTROL_CONDITIONAL_EXECUTING; + break; + } + } + + /*lint -fallthrough */ + + case AML_IF_OP: + + /* + * IF/WHILE: Create a new control state to manage these + * constructs. We need to manage these as a stack, in order + * to handle nesting. + */ + ControlState = AcpiUtCreateControlState (); + if (!ControlState) + { + Status = AE_NO_MEMORY; + break; + } + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; + ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; + ControlState->Control.Opcode = Op->Common.AmlOpcode; + + + /* Push the control state on this walk's control stack */ + + AcpiUtPushGenericState (&WalkState->ControlState, ControlState); + break; + + case AML_ELSE_OP: + + /* Predicate is in the state object */ + /* If predicate is true, the IF was executed, ignore ELSE part */ + + if (WalkState->LastPredicate) + { + Status = AE_CTRL_TRUE; + } + + break; + + case AML_RETURN_OP: + + break; + + default: + break; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecEndControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecEndControlOp); + + + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); + + /* + * Save the result of the predicate in case there is an + * ELSE to come + */ + WalkState->LastPredicate = + (BOOLEAN) WalkState->ControlState->Common.Value; + + /* + * Pop the control state that was created at the start + * of the IF and free it + */ + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_ELSE_OP: + + break; + + + case AML_WHILE_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); + + ControlState = WalkState->ControlState; + if (ControlState->Common.Value) + { + /* Predicate was true, the body of the loop was just executed */ + + /* + * This loop counter mechanism allows the interpreter to escape + * possibly infinite loops. This can occur in poorly written AML + * when the hardware does not respond within a while loop and the + * loop does not implement a timeout. + */ + ControlState->Control.LoopCount++; + if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) + { + Status = AE_AML_INFINITE_LOOP; + break; + } + + /* + * Go back and evaluate the predicate and maybe execute the loop + * another time + */ + Status = AE_CTRL_PENDING; + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + break; + } + + /* Predicate was false, terminate this while loop */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n",Op)); + + /* Pop this control state and free it */ + + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_RETURN_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); + + /* + * One optional operand -- the return value + * It can be either an immediate operand or a result that + * has been bubbled up the tree + */ + if (Op->Common.Value.Arg) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* Return statement has an immediate operand */ + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Get the return value and save as the last result + * value. This is the only place where WalkState->ReturnDesc + * is set to anything other than zero! + */ + WalkState->ReturnDesc = WalkState->Operands[0]; + } + else if (WalkState->ResultCount) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + * + * Allow references created by the Index operator to return + * unchanged. + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && + ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) + { + Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; + } + else + { + /* No return operand */ + + if (WalkState->NumOperands) + { + AcpiUtRemoveReference (WalkState->Operands [0]); + } + + WalkState->Operands [0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + } + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Completed RETURN_OP State=%p, RetVal=%p\n", + WalkState, WalkState->ReturnDesc)); + + /* End the control method execution right now */ + + Status = AE_CTRL_TERMINATE; + break; + + + case AML_NOOP_OP: + + /* Just do nothing! */ + break; + + + case AML_BREAK_POINT_OP: + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + ACPI_DEBUGGER_EXEC ( + AcpiGbl_CmSingleStep = TRUE); + ACPI_DEBUGGER_EXEC ( + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); + + /* Call to the OSL in case OS wants a piece of the action */ + + Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); + break; + + + case AML_BREAK_OP: + case AML_CONTINUE_OP: /* ACPI 2.0 */ + + + /* Pop and delete control states until we find a while */ + + while (WalkState->ControlState && + (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) + { + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + } + + /* No while found? */ + + if (!WalkState->ControlState) + { + return (AE_AML_NO_WHILE); + } + + /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ + + WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; + + /* Return status depending on opcode */ + + if (Op->Common.AmlOpcode == AML_BREAK_OP) + { + Status = AE_CTRL_BREAK; + } + else + { + Status = AE_CTRL_CONTINUE; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p", + Op->Common.AmlOpcode, Op)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + return (Status); +} diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsfield.c b/sys/contrib/dev/acpica-unix/dispatcher/dsfield.c index 2d8e58689b..39d2e885a0 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsfield.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -211,9 +211,12 @@ AcpiDsCreateBufferField ( Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; - /* Mark node temporary if we are executing a method */ - - if (WalkState->MethodNode) + /* + * Mark node temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) { Flags |= ACPI_NS_TEMPORARY; } @@ -311,7 +314,7 @@ AcpiDsGetFieldNames ( ACPI_PARSE_OBJECT *Arg) { ACPI_STATUS Status; - ACPI_INTEGER Position; + UINT64 Position; ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); @@ -335,8 +338,8 @@ AcpiDsGetFieldNames ( { case AML_INT_RESERVEDFIELD_OP: - Position = (ACPI_INTEGER) Info->FieldBitPosition - + (ACPI_INTEGER) Arg->Common.Value.Size; + Position = (UINT64) Info->FieldBitPosition + + (UINT64) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { @@ -403,8 +406,8 @@ AcpiDsGetFieldNames ( /* Keep track of bit position for the next field */ - Position = (ACPI_INTEGER) Info->FieldBitPosition - + (ACPI_INTEGER) Arg->Common.Value.Size; + Position = (UINT64) Info->FieldBitPosition + + (UINT64) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { @@ -421,7 +424,7 @@ AcpiDsGetFieldNames ( default: ACPI_ERROR ((AE_INFO, - "Invalid opcode in field list: %X", Arg->Common.AmlOpcode)); + "Invalid opcode in field list: 0x%X", Arg->Common.AmlOpcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } @@ -566,9 +569,12 @@ AcpiDsInitFieldObjects ( Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; - /* Mark node(s) temporary if we are executing a method */ - - if (WalkState->MethodNode) + /* + * Mark node(s) temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) { Flags |= ACPI_NS_TEMPORARY; } diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsinit.c b/sys/contrib/dev/acpica-unix/dispatcher/dsinit.c index af29476410..f9d1e2498b 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsinit.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -263,12 +263,12 @@ AcpiDsInitializeObjects ( "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); - Info.MethodCount = 0; - Info.OpRegionCount = 0; - Info.ObjectCount = 0; - Info.DeviceCount = 0; - Info.TableIndex = TableIndex; - Info.OwnerId = OwnerId; + /* Set all init info to zero */ + + ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + + Info.OwnerId = OwnerId; + Info.TableIndex = TableIndex; /* Walk entire namespace from the supplied root */ @@ -283,7 +283,7 @@ AcpiDsInitializeObjects ( * the namespace reader lock. */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, &Info, NULL); + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); @@ -297,12 +297,12 @@ AcpiDsInitializeObjects ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", + "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n", Table->Signature, OwnerId, Info.ObjectCount, Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount)); + "%u Methods, %u Regions\n", Info.MethodCount, Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsmethod.c b/sys/contrib/dev/acpica-unix/dispatcher/dsmethod.c index d4127fd769..8f7d6bd15d 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsmethod.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsmethod.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,6 @@ #include "acpi.h" #include "accommon.h" -#include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" @@ -291,7 +290,7 @@ AcpiDsBeginMethodExecution ( /* * If this method is serialized, we need to acquire the method mutex. */ - if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) + if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED) { /* * Create a mutex for the method if it is defined to be Serialized @@ -318,7 +317,7 @@ AcpiDsBeginMethodExecution ( (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) { ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", + "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)", AcpiUtGetNodeName (MethodNode), WalkState->Thread->CurrentSyncLevel)); @@ -517,9 +516,9 @@ AcpiDsCallControlMethod ( /* Invoke an internal method if necessary */ - if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + if (ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY) { - Status = ObjDesc->Method.Implementation (NextWalkState); + Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState); if (Status == AE_OK) { Status = AE_CTRL_TERMINATE; @@ -693,10 +692,33 @@ AcpiDsTerminateControlMethod ( } /* - * Delete any namespace objects created anywhere within - * the namespace by the execution of this method + * Delete any namespace objects created anywhere within the + * namespace by the execution of this method. Unless: + * 1) This method is a module-level executable code method, in which + * case we want make the objects permanent. + * 2) There are other threads executing the method, in which case we + * will wait until the last thread has completed. */ - AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) && + (MethodDesc->Method.ThreadCount == 1)) + { + /* Delete any direct children of (created by) this method */ + + AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode); + + /* + * Delete any objects that were created by this method + * elsewhere in the namespace (if any were created). + * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the + * deletion such that we don't have to perform an entire + * namespace walk for every control method execution. + */ + if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE) + { + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_MODIFIED_NAMESPACE; + } + } } /* Decrement the thread count on the method */ @@ -720,7 +742,7 @@ AcpiDsTerminateControlMethod ( * we immediately reuse it for the next thread executing this method */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "*** Completed execution of one thread, %d threads remaining\n", + "*** Completed execution of one thread, %u threads remaining\n", MethodDesc->Method.ThreadCount)); } else @@ -732,20 +754,42 @@ AcpiDsTerminateControlMethod ( * Serialized if it appears that the method is incorrectly written and * does not support multiple thread execution. The best example of this * is if such a method creates namespace objects and blocks. A second - * thread will fail with an AE_ALREADY_EXISTS exception + * thread will fail with an AE_ALREADY_EXISTS exception. * * This code is here because we must wait until the last thread exits - * before creating the synchronization semaphore. + * before marking the method as serialized. */ - if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && - (!MethodDesc->Method.Mutex)) + if (MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED_PENDING) { - (void) AcpiDsCreateMethodMutex (MethodDesc); + if (WalkState) + { + ACPI_INFO ((AE_INFO, + "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", + WalkState->MethodNode->Name.Ascii)); + } + + /* + * Method tried to create an object twice and was marked as + * "pending serialized". The probable cause is that the method + * cannot handle reentrancy. + * + * The method was created as NotSerialized, but it tried to create + * a named object and then blocked, causing the second thread + * entrance to begin and then fail. Workaround this problem by + * marking the method permanently as Serialized when the last + * thread exits here. + */ + MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING; + MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED; + MethodDesc->Method.SyncLevel = 0; } /* No more threads, we can free the OwnerId */ - AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)) + { + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + } } return_VOID; diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsmthdat.c b/sys/contrib/dev/acpica-unix/dispatcher/dsmthdat.c index 809ef1f0e8..a264b3aba1 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsmthdat.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsmthdat.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -188,8 +188,7 @@ AcpiDsMethodDataInit ( WalkState->Arguments[i].Name.Integer |= (i << 24); WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; WalkState->Arguments[i].Type = ACPI_TYPE_ANY; - WalkState->Arguments[i].Flags = - ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG; } /* Init the method locals */ @@ -201,8 +200,7 @@ AcpiDsMethodDataInit ( WalkState->LocalVariables[i].Name.Integer |= (i << 24); WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; - WalkState->LocalVariables[i].Flags = - ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL; } return_VOID; @@ -238,7 +236,7 @@ AcpiDsMethodDataDeleteAll ( { if (WalkState->LocalVariables[Index].Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n", Index, WalkState->LocalVariables[Index].Object)); /* Detach object (if present) and remove a reference */ @@ -253,7 +251,7 @@ AcpiDsMethodDataDeleteAll ( { if (WalkState->Arguments[Index].Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n", Index, WalkState->Arguments[Index].Object)); /* Detach object (if present) and remove a reference */ @@ -322,7 +320,7 @@ AcpiDsMethodDataInitArgs ( Index++; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index)); return_ACPI_STATUS (AE_OK); } @@ -363,7 +361,7 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_LOCAL) { ACPI_ERROR ((AE_INFO, - "Local index %d is invalid (max %d)", + "Local index %u is invalid (max %u)", Index, ACPI_METHOD_MAX_LOCAL)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -378,7 +376,7 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_ARG) { ACPI_ERROR ((AE_INFO, - "Arg index %d is invalid (max %d)", + "Arg index %u is invalid (max %u)", Index, ACPI_METHOD_MAX_ARG)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -389,7 +387,7 @@ AcpiDsMethodDataGetNode ( break; default: - ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type)); + ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type)); return_ACPI_STATUS (AE_TYPE); } @@ -429,7 +427,7 @@ AcpiDsMethodDataSetValue ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object, + "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object, Type, Object->Common.ReferenceCount, AcpiUtGetTypeName (Object->Common.Type))); @@ -524,13 +522,12 @@ AcpiDsMethodDataGetValue ( if (AcpiGbl_EnableInterpreterSlack) { - Object = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + Object = AcpiUtCreateIntegerObject ((UINT64) 0); if (!Object) { return_ACPI_STATUS (AE_NO_MEMORY); } - Object->Integer.Value = 0; Node->Object = Object; } @@ -541,21 +538,22 @@ AcpiDsMethodDataGetValue ( case ACPI_REFCLASS_ARG: ACPI_ERROR ((AE_INFO, - "Uninitialized Arg[%d] at node %p", + "Uninitialized Arg[%u] at node %p", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); case ACPI_REFCLASS_LOCAL: - ACPI_ERROR ((AE_INFO, - "Uninitialized Local[%d] at node %p", Index, Node)); - + /* + * No error message for this case, will be trapped again later to + * detect and ignore cases of Store(LocalX,LocalX) + */ return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); default: - ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type)); + ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type)); return_ACPI_STATUS (AE_AML_INTERNAL); } } @@ -667,7 +665,7 @@ AcpiDsStoreObjectToLocal ( ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n", Type, Index, ObjDesc)); /* Parameter validation */ diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsobject.c b/sys/contrib/dev/acpica-unix/dispatcher/dsobject.c index 647adb2b62..abf8672f2e 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsobject.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -159,6 +159,7 @@ AcpiDsBuildInternalObject ( { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; ACPI_FUNCTION_TRACE (DsBuildInternalObject); @@ -241,7 +242,20 @@ AcpiDsBuildInternalObject ( return_ACPI_STATUS (Status); } - switch (Op->Common.Node->Type) + /* + * Special handling for Alias objects. We need to setup the type + * and the Op->Common.Node to point to the Alias target. Note, + * Alias has at most one level of indirection internally. + */ + Type = Op->Common.Node->Type; + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ObjDesc->Common.Type; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + Op->Common.Node->Object); + } + + switch (Type) { /* * For these types, we need the actual node, not the subobject. @@ -365,7 +379,7 @@ AcpiDsBuildInternalBufferObj ( if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) { ACPI_ERROR ((AE_INFO, - "Expecting bytelist, got AML opcode %X in op %p", + "Expecting bytelist, found AML opcode 0x%X in op %p", ByteList->Common.AmlOpcode, ByteList)); AcpiUtRemoveReference (ObjDesc); @@ -570,23 +584,36 @@ AcpiDsBuildInternalPackageObj ( { /* * NumElements was exhausted, but there are remaining elements in the - * PackageList. + * PackageList. Truncate the package to NumElements. * * Note: technically, this is an error, from ACPI spec: "It is an error * for NumElements to be less than the number of elements in the - * PackageList". However, for now, we just print an error message and - * no exception is returned. + * PackageList". However, we just print a message and + * no exception is returned. This provides Windows compatibility. Some + * BIOSs will alter the NumElements on the fly, creating this type + * of ill-formed package object. */ while (Arg) { + /* + * We must delete any package elements that were created earlier + * and are not going to be used because of the package truncation. + */ + if (Arg->Common.Node) + { + AcpiUtRemoveReference ( + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node)); + Arg->Common.Node = NULL; + } + /* Find out how many elements there really are */ i++; Arg = Arg->Common.Next; } - ACPI_ERROR ((AE_INFO, - "Package List length (%X) larger than NumElements count (%X), truncated\n", + ACPI_INFO ((AE_INFO, + "Actual Package length (%u) is larger than NumElements field (%u), truncated\n", i, ElementCount)); } else if (i < ElementCount) @@ -596,7 +623,7 @@ AcpiDsBuildInternalPackageObj ( * Note: this is not an error, the package is padded out with NULLs. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Package List length (%X) smaller than NumElements count (%X), padded with null elements\n", + "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n", i, ElementCount)); } @@ -774,7 +801,7 @@ AcpiDsInitObjectFromOp ( case AML_ONES_OP: - ObjDesc->Integer.Value = ACPI_INTEGER_MAX; + ObjDesc->Integer.Value = ACPI_UINT64_MAX; /* Truncate value if we are executing from a 32-bit ACPI table */ @@ -791,7 +818,7 @@ AcpiDsInitObjectFromOp ( default: ACPI_ERROR ((AE_INFO, - "Unknown constant opcode %X", Opcode)); + "Unknown constant opcode 0x%X", Opcode)); Status = AE_AML_OPERAND_TYPE; break; } @@ -808,7 +835,7 @@ AcpiDsInitObjectFromOp ( default: - ACPI_ERROR ((AE_INFO, "Unknown Integer type %X", + ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X", OpInfo->Type)); Status = AE_AML_OPERAND_TYPE; break; @@ -889,7 +916,7 @@ AcpiDsInitObjectFromOp ( default: ACPI_ERROR ((AE_INFO, - "Unimplemented reference type for AML opcode: %4.4X", Opcode)); + "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } break; @@ -899,7 +926,7 @@ AcpiDsInitObjectFromOp ( default: - ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", + ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X", ObjDesc->Common.Type)); Status = AE_AML_OPERAND_TYPE; diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsopcode.c b/sys/contrib/dev/acpica-unix/dispatcher/dsopcode.c index 3edbacc1d9..0f5164e96f 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsopcode.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsopcode.c @@ -1,7 +1,6 @@ /****************************************************************************** * - * Module Name: dsopcode - Dispatcher Op Region support and handling of - * "control" opcodes + * Module Name: dsopcode - Dispatcher suport for regions and fields * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -131,13 +130,6 @@ /* Local prototypes */ -static ACPI_STATUS -AcpiDsExecuteArguments ( - ACPI_NAMESPACE_NODE *Node, - ACPI_NAMESPACE_NODE *ScopeNode, - UINT32 AmlLength, - UINT8 *AmlStart); - static ACPI_STATUS AcpiDsInitBufferField ( UINT16 AmlOpcode, @@ -148,369 +140,6 @@ AcpiDsInitBufferField ( ACPI_OPERAND_OBJECT *ResultDesc); -/******************************************************************************* - * - * FUNCTION: AcpiDsExecuteArguments - * - * PARAMETERS: Node - Object NS node - * ScopeNode - Parent NS node - * AmlLength - Length of executable AML - * AmlStart - Pointer to the AML - * - * RETURN: Status. - * - * DESCRIPTION: Late (deferred) execution of region or field arguments - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDsExecuteArguments ( - ACPI_NAMESPACE_NODE *Node, - ACPI_NAMESPACE_NODE *ScopeNode, - UINT32 AmlLength, - UINT8 *AmlStart) -{ - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *Op; - ACPI_WALK_STATE *WalkState; - - - ACPI_FUNCTION_TRACE (DsExecuteArguments); - - - /* - * Allocate a new parser op to be the root of the parsed tree - */ - Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Save the Node for use in AcpiPsParseAml */ - - Op->Common.Node = ScopeNode; - - /* Create and initialize a new parser state */ - - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); - if (!WalkState) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; - } - - /* Mark this parse as a deferred opcode */ - - WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; - WalkState->DeferredNode = Node; - - /* Pass1: Parse the entire declaration */ - - Status = AcpiPsParseAml (WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Get and init the Op created above */ - - Op->Common.Node = Node; - AcpiPsDeleteParseTree (Op); - - /* Evaluate the deferred arguments */ - - Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - Op->Common.Node = ScopeNode; - - /* Create and initialize a new parser state */ - - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); - if (!WalkState) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Execute the opcode and arguments */ - - Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, ACPI_IMODE_EXECUTE); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; - } - - /* Mark this execution as a deferred opcode */ - - WalkState->DeferredNode = Node; - Status = AcpiPsParseAml (WalkState); - -Cleanup: - AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsGetBufferFieldArguments - * - * PARAMETERS: ObjDesc - A valid BufferField object - * - * RETURN: Status. - * - * DESCRIPTION: Get BufferField Buffer and Index. This implements the late - * evaluation of these field attributes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsGetBufferFieldArguments ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_OPERAND_OBJECT *ExtraDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); - - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the AML pointer (method object) and BufferField node */ - - ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); - Node = ObjDesc->BufferField.Node; - - ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", - AcpiUtGetNodeName (Node))); - - /* Execute the AML code for the TermArg arguments */ - - Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsGetBankFieldArguments - * - * PARAMETERS: ObjDesc - A valid BankField object - * - * RETURN: Status. - * - * DESCRIPTION: Get BankField BankValue. This implements the late - * evaluation of these field attributes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsGetBankFieldArguments ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_OPERAND_OBJECT *ExtraDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc); - - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the AML pointer (method object) and BankField node */ - - ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); - Node = ObjDesc->BankField.Node; - - ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", - AcpiUtGetNodeName (Node))); - - /* Execute the AML code for the TermArg arguments */ - - Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsGetBufferArguments - * - * PARAMETERS: ObjDesc - A valid Buffer object - * - * RETURN: Status. - * - * DESCRIPTION: Get Buffer length and initializer byte list. This implements - * the late evaluation of these attributes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsGetBufferArguments ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); - - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the Buffer node */ - - Node = ObjDesc->Buffer.Node; - if (!Node) - { - ACPI_ERROR ((AE_INFO, - "No pointer back to NS node in buffer obj %p", ObjDesc)); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); - - /* Execute the AML code for the TermArg arguments */ - - Status = AcpiDsExecuteArguments (Node, Node, - ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsGetPackageArguments - * - * PARAMETERS: ObjDesc - A valid Package object - * - * RETURN: Status. - * - * DESCRIPTION: Get Package length and initializer byte list. This implements - * the late evaluation of these attributes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsGetPackageArguments ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); - - - if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the Package node */ - - Node = ObjDesc->Package.Node; - if (!Node) - { - ACPI_ERROR ((AE_INFO, - "No pointer back to NS node in package %p", ObjDesc)); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); - - /* Execute the AML code for the TermArg arguments */ - - Status = AcpiDsExecuteArguments (Node, Node, - ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); - return_ACPI_STATUS (Status); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiDsGetRegionArguments - * - * PARAMETERS: ObjDesc - A valid region object - * - * RETURN: Status. - * - * DESCRIPTION: Get region address and length. This implements the late - * evaluation of these region attributes. - * - ****************************************************************************/ - -ACPI_STATUS -AcpiDsGetRegionArguments ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ExtraDesc; - - - ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); - - - if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) - { - return_ACPI_STATUS (AE_OK); - } - - ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); - if (!ExtraDesc) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } - - /* Get the Region node */ - - Node = ObjDesc->Region.Node; - - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", - AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); - - /* Execute the argument AML */ - - Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), - ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); - return_ACPI_STATUS (Status); -} - - /******************************************************************************* * * FUNCTION: AcpiDsInitializeRegion @@ -678,7 +307,7 @@ AcpiDsInitBufferField ( default: ACPI_ERROR ((AE_INFO, - "Unknown field creation opcode %02x", + "Unknown field creation opcode 0x%02X", AmlOpcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -690,7 +319,7 @@ AcpiDsInitBufferField ( (8 * (UINT32) BufferDesc->Buffer.Length)) { ACPI_ERROR ((AE_INFO, - "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", + "Field [%4.4s] at %u exceeds Buffer [%4.4s] size %u (bits)", AcpiUtGetNodeName (ResultDesc), BitOffset + BitCount, AcpiUtGetNodeName (BufferDesc->Buffer.Node), @@ -806,7 +435,7 @@ AcpiDsEvalBufferFieldOperands ( ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "(%s) bad operand(s) (%X)", + ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X", AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); return_ACPI_STATUS (Status); @@ -942,8 +571,9 @@ AcpiDsEvalRegionOperands ( * * RETURN: Status * - * DESCRIPTION: Get region address and length - * Called from AcpiDsExecEndOp during DataTableRegion parse tree walk + * DESCRIPTION: Get region address and length. + * Called from AcpiDsExecEndOp during DataTableRegion parse + * tree walk. * ******************************************************************************/ @@ -1249,371 +879,3 @@ AcpiDsEvalBankFieldOperands ( return_ACPI_STATUS (Status); } - -/******************************************************************************* - * - * FUNCTION: AcpiDsExecBeginControlOp - * - * PARAMETERS: WalkList - The list that owns the walk stack - * Op - The control Op - * - * RETURN: Status - * - * DESCRIPTION: Handles all control ops encountered during control method - * execution. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsExecBeginControlOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GENERIC_STATE *ControlState; - - - ACPI_FUNCTION_NAME (DsExecBeginControlOp); - - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, - Op->Common.AmlOpcode, WalkState)); - - switch (Op->Common.AmlOpcode) - { - case AML_WHILE_OP: - - /* - * If this is an additional iteration of a while loop, continue. - * There is no need to allocate a new control state. - */ - if (WalkState->ControlState) - { - if (WalkState->ControlState->Control.AmlPredicateStart == - (WalkState->ParserState.Aml - 1)) - { - /* Reset the state to start-of-loop */ - - WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; - break; - } - } - - /*lint -fallthrough */ - - case AML_IF_OP: - - /* - * IF/WHILE: Create a new control state to manage these - * constructs. We need to manage these as a stack, in order - * to handle nesting. - */ - ControlState = AcpiUtCreateControlState (); - if (!ControlState) - { - Status = AE_NO_MEMORY; - break; - } - /* - * Save a pointer to the predicate for multiple executions - * of a loop - */ - ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; - ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; - ControlState->Control.Opcode = Op->Common.AmlOpcode; - - - /* Push the control state on this walk's control stack */ - - AcpiUtPushGenericState (&WalkState->ControlState, ControlState); - break; - - case AML_ELSE_OP: - - /* Predicate is in the state object */ - /* If predicate is true, the IF was executed, ignore ELSE part */ - - if (WalkState->LastPredicate) - { - Status = AE_CTRL_TRUE; - } - - break; - - case AML_RETURN_OP: - - break; - - default: - break; - } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsExecEndControlOp - * - * PARAMETERS: WalkList - The list that owns the walk stack - * Op - The control Op - * - * RETURN: Status - * - * DESCRIPTION: Handles all control ops encountered during control method - * execution. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsExecEndControlOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GENERIC_STATE *ControlState; - - - ACPI_FUNCTION_NAME (DsExecEndControlOp); - - - switch (Op->Common.AmlOpcode) - { - case AML_IF_OP: - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); - - /* - * Save the result of the predicate in case there is an - * ELSE to come - */ - WalkState->LastPredicate = - (BOOLEAN) WalkState->ControlState->Common.Value; - - /* - * Pop the control state that was created at the start - * of the IF and free it - */ - ControlState = AcpiUtPopGenericState (&WalkState->ControlState); - AcpiUtDeleteGenericState (ControlState); - break; - - - case AML_ELSE_OP: - - break; - - - case AML_WHILE_OP: - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); - - ControlState = WalkState->ControlState; - if (ControlState->Common.Value) - { - /* Predicate was true, the body of the loop was just executed */ - - /* - * This loop counter mechanism allows the interpreter to escape - * possibly infinite loops. This can occur in poorly written AML - * when the hardware does not respond within a while loop and the - * loop does not implement a timeout. - */ - ControlState->Control.LoopCount++; - if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) - { - Status = AE_AML_INFINITE_LOOP; - break; - } - - /* - * Go back and evaluate the predicate and maybe execute the loop - * another time - */ - Status = AE_CTRL_PENDING; - WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; - break; - } - - /* Predicate was false, terminate this while loop */ - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[WHILE_OP] termination! Op=%p\n",Op)); - - /* Pop this control state and free it */ - - ControlState = AcpiUtPopGenericState (&WalkState->ControlState); - AcpiUtDeleteGenericState (ControlState); - break; - - - case AML_RETURN_OP: - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); - - /* - * One optional operand -- the return value - * It can be either an immediate operand or a result that - * has been bubbled up the tree - */ - if (Op->Common.Value.Arg) - { - /* Since we have a real Return(), delete any implicit return */ - - AcpiDsClearImplicitReturn (WalkState); - - /* Return statement has an immediate operand */ - - Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * If value being returned is a Reference (such as - * an arg or local), resolve it now because it may - * cease to exist at the end of the method. - */ - Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* - * Get the return value and save as the last result - * value. This is the only place where WalkState->ReturnDesc - * is set to anything other than zero! - */ - WalkState->ReturnDesc = WalkState->Operands[0]; - } - else if (WalkState->ResultCount) - { - /* Since we have a real Return(), delete any implicit return */ - - AcpiDsClearImplicitReturn (WalkState); - - /* - * The return value has come from a previous calculation. - * - * If value being returned is a Reference (such as - * an arg or local), resolve it now because it may - * cease to exist at the end of the method. - * - * Allow references created by the Index operator to return unchanged. - */ - if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && - ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && - ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) - { - Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - - WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; - } - else - { - /* No return operand */ - - if (WalkState->NumOperands) - { - AcpiUtRemoveReference (WalkState->Operands [0]); - } - - WalkState->Operands [0] = NULL; - WalkState->NumOperands = 0; - WalkState->ReturnDesc = NULL; - } - - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Completed RETURN_OP State=%p, RetVal=%p\n", - WalkState, WalkState->ReturnDesc)); - - /* End the control method execution right now */ - - Status = AE_CTRL_TERMINATE; - break; - - - case AML_NOOP_OP: - - /* Just do nothing! */ - break; - - - case AML_BREAK_POINT_OP: - - /* - * Set the single-step flag. This will cause the debugger (if present) - * to break to the console within the AML debugger at the start of the - * next AML instruction. - */ - ACPI_DEBUGGER_EXEC ( - AcpiGbl_CmSingleStep = TRUE); - ACPI_DEBUGGER_EXEC ( - AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); - - /* Call to the OSL in case OS wants a piece of the action */ - - Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, - "Executed AML Breakpoint opcode"); - break; - - - case AML_BREAK_OP: - case AML_CONTINUE_OP: /* ACPI 2.0 */ - - - /* Pop and delete control states until we find a while */ - - while (WalkState->ControlState && - (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) - { - ControlState = AcpiUtPopGenericState (&WalkState->ControlState); - AcpiUtDeleteGenericState (ControlState); - } - - /* No while found? */ - - if (!WalkState->ControlState) - { - return (AE_AML_NO_WHILE); - } - - /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ - - WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; - - /* Return status depending on opcode */ - - if (Op->Common.AmlOpcode == AML_BREAK_OP) - { - Status = AE_CTRL_BREAK; - } - else - { - Status = AE_CTRL_CONTINUE; - } - break; - - - default: - - ACPI_ERROR ((AE_INFO, "Unknown control opcode=%X Op=%p", - Op->Common.AmlOpcode, Op)); - - Status = AE_AML_BAD_OPCODE; - break; - } - - return (Status); -} - diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dsutils.c b/sys/contrib/dev/acpica-unix/dispatcher/dsutils.c index 6c211ace8c..22bd0bf900 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dsutils.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dsutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -875,7 +875,7 @@ AcpiDsCreateOperands ( Index--; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n", Index, Arg, FirstArg)); } @@ -890,7 +890,7 @@ Cleanup: */ AcpiDsObjStackPopAndDelete (ArgCount, WalkState); - ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", Index)); + ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index)); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dswexec.c b/sys/contrib/dev/acpica-unix/dispatcher/dswexec.c index 9485c62bb1..e243c7f769 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dswexec.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dswexec.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -227,7 +227,7 @@ AcpiDsGetPredicateValue ( if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, - "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=0x%X", ObjDesc, WalkState, ObjDesc->Common.Type)); Status = AE_AML_OPERAND_TYPE; @@ -400,10 +400,26 @@ AcpiDsExecBeginOp ( * we must enter this object into the namespace. The created * object is temporary and will be deleted upon completion of * the execution of this method. + * + * Note 10/2010: Except for the Scope() op. This opcode does + * not actually create a new object, it refers to an existing + * object. However, for Scope(), we want to indeed open a + * new scope. */ - Status = AcpiDsLoad2BeginOp (WalkState, NULL); + if (Op->Common.AmlOpcode != AML_SCOPE_OP) + { + Status = AcpiDsLoad2BeginOp (WalkState, NULL); + } + else + { + Status = AcpiDsScopeStackPush (Op->Named.Node, + Op->Named.Node->Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } } - break; @@ -463,7 +479,7 @@ AcpiDsExecEndOp ( if (OpClass == AML_CLASS_UNKNOWN) { - ACPI_ERROR ((AE_INFO, "Unknown opcode %X", Op->Common.AmlOpcode)); + ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } @@ -783,7 +799,7 @@ AcpiDsExecEndOp ( default: ACPI_ERROR ((AE_INFO, - "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p", + "Unimplemented opcode, class=0x%X type=0x%X Opcode=-0x%X Op=%p", OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dswload.c b/sys/contrib/dev/acpica-unix/dispatcher/dswload.c index d5a642ce70..4988ee3f69 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dswload.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dswload.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dswload - Dispatcher namespace load callbacks + * Module Name: dswload - Dispatcher first pass namespace load callbacks * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -122,7 +122,6 @@ #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" -#include "acevents.h" #ifdef ACPI_ASL_COMPILER #include "acdisasm.h" @@ -263,7 +262,7 @@ AcpiDsLoad1BeginOp ( * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Path, ACPI_TYPE_DEVICE, 0); + AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &Node); @@ -296,18 +295,19 @@ AcpiDsLoad1BeginOp ( case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This - * enables some existing code of the form: + * These types we will allow, but we will change the type. + * This enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } * - * Note: silently change the type here. On the second pass, we will report - * a warning + * Note: silently change the type here. On the second pass, + * we will report a warning */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", - Path, AcpiUtGetTypeName (Node->Type))); + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; @@ -318,8 +318,9 @@ AcpiDsLoad1BeginOp ( /* All other types are an error */ ACPI_ERROR ((AE_INFO, - "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", - AcpiUtGetTypeName (Node->Type), Path)); + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -620,697 +621,3 @@ AcpiDsLoad1EndOp ( return_ACPI_STATUS (Status); } - - -/******************************************************************************* - * - * FUNCTION: AcpiDsLoad2BeginOp - * - * PARAMETERS: WalkState - Current state of the parse tree walk - * OutOp - Wher to return op if a new one is created - * - * RETURN: Status - * - * DESCRIPTION: Descending callback used during the loading of ACPI tables. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsLoad2BeginOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT **OutOp) -{ - ACPI_PARSE_OBJECT *Op; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_OBJECT_TYPE ObjectType; - char *BufferPtr; - UINT32 Flags; - - - ACPI_FUNCTION_TRACE (DsLoad2BeginOp); - - - Op = WalkState->Op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); - - if (Op) - { - if ((WalkState->ControlState) && - (WalkState->ControlState->Common.State == - ACPI_CONTROL_CONDITIONAL_EXECUTING)) - { - /* We are executing a while loop outside of a method */ - - Status = AcpiDsExecBeginOp (WalkState, OutOp); - return_ACPI_STATUS (Status); - } - - /* We only care about Namespace opcodes here */ - - if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && - (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || - (!(WalkState->OpInfo->Flags & AML_NAMED))) - { -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Begin/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecBeginOp (WalkState, OutOp); - return_ACPI_STATUS (Status); - } -#endif - return_ACPI_STATUS (AE_OK); - } - - /* Get the name we are going to enter or lookup in the namespace */ - - if (WalkState->Opcode == AML_INT_NAMEPATH_OP) - { - /* For Namepath op, get the path string */ - - BufferPtr = Op->Common.Value.String; - if (!BufferPtr) - { - /* No name, just exit */ - - return_ACPI_STATUS (AE_OK); - } - } - else - { - /* Get name from the op */ - - BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); - } - } - else - { - /* Get the namestring from the raw AML */ - - BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); - } - - /* Map the opcode into an internal object type */ - - ObjectType = WalkState->OpInfo->ObjectType; - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); - - switch (WalkState->Opcode) - { - case AML_FIELD_OP: - case AML_BANK_FIELD_OP: - case AML_INDEX_FIELD_OP: - - Node = NULL; - Status = AE_OK; - break; - - case AML_INT_NAMEPATH_OP: - /* - * The NamePath is an object reference to an existing object. - * Don't enter the name into the namespace, but look it up - * for use later. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); - break; - - case AML_SCOPE_OP: - /* - * The Path is an object reference to an existing object. - * Don't enter the name into the namespace, but look it up - * for use later. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); - if (ACPI_FAILURE (Status)) - { -#ifdef ACPI_ASL_COMPILER - if (Status == AE_NOT_FOUND) - { - Status = AE_OK; - } - else - { - ACPI_ERROR_NAMESPACE (BufferPtr, Status); - } -#else - ACPI_ERROR_NAMESPACE (BufferPtr, Status); -#endif - return_ACPI_STATUS (Status); - } - - /* - * We must check to make sure that the target is - * one of the opcodes that actually opens a scope - */ - switch (Node->Type) - { - case ACPI_TYPE_ANY: - case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - - /* These are acceptable types */ - break; - - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* - * These types we will allow, but we will change the type. This - * enables some existing code of the form: - * - * Name (DEB, 0) - * Scope (DEB) { ... } - */ - ACPI_WARNING ((AE_INFO, - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", - BufferPtr, AcpiUtGetTypeName (Node->Type))); - - Node->Type = ACPI_TYPE_ANY; - WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; - break; - - default: - - /* All other types are an error */ - - ACPI_ERROR ((AE_INFO, - "Invalid type (%s) for target of Scope operator [%4.4s]", - AcpiUtGetTypeName (Node->Type), BufferPtr)); - - return (AE_AML_OPERAND_TYPE); - } - break; - - default: - - /* All other opcodes */ - - if (Op && Op->Common.Node) - { - /* This op/node was previously entered into the namespace */ - - Node = Op->Common.Node; - - if (AcpiNsOpensScope (ObjectType)) - { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - return_ACPI_STATUS (AE_OK); - } - - /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that - * involve arguments to the opcode must be created as we go back up the - * parse tree later. - * - * Note: Name may already exist if we are executing a deferred opcode. - */ - if (WalkState->DeferredNode) - { - /* This name is already in the namespace, get the node */ - - Node = WalkState->DeferredNode; - Status = AE_OK; - break; - } - - Flags = ACPI_NS_NO_UPSEARCH; - if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) - { - /* Execution mode, node cannot already exist, node is temporary */ - - Flags |= (ACPI_NS_ERROR_IF_FOUND | ACPI_NS_TEMPORARY); - } - - /* Add new entry or lookup existing entry */ - - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); - - if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "***New Node [%4.4s] %p is temporary\n", - AcpiUtGetNodeName (Node), Node)); - } - break; - } - - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR_NAMESPACE (BufferPtr, Status); - return_ACPI_STATUS (Status); - } - - if (!Op) - { - /* Create a new op */ - - Op = AcpiPsAllocOp (WalkState->Opcode); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Initialize the new op */ - - if (Node) - { - Op->Named.Name = Node->Name.Integer; - } - *OutOp = Op; - } - - /* - * Put the Node in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - Op->Common.Node = Node; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsLoad2EndOp - * - * PARAMETERS: WalkState - Current state of the parse tree walk - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback used during the loading of the namespace, - * both control methods and everything else. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsLoad2EndOp ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_PARSE_OBJECT *Op; - ACPI_STATUS Status = AE_OK; - ACPI_OBJECT_TYPE ObjectType; - ACPI_NAMESPACE_NODE *Node; - ACPI_PARSE_OBJECT *Arg; - ACPI_NAMESPACE_NODE *NewNode; -#ifndef ACPI_NO_METHOD_EXECUTION - UINT32 i; - UINT8 RegionSpace; -#endif - - - ACPI_FUNCTION_TRACE (DsLoad2EndOp); - - Op = WalkState->Op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", - WalkState->OpInfo->Name, Op, WalkState)); - - /* Check if opcode had an associated namespace object */ - - if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) - { -#ifndef ACPI_NO_METHOD_EXECUTION -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - /* No namespace object. Executable opcode? */ - - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "End/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecEndOp (WalkState); - return_ACPI_STATUS (Status); - } -#endif -#endif - return_ACPI_STATUS (AE_OK); - } - - if (Op->Common.AmlOpcode == AML_SCOPE_OP) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Ending scope Op=%p State=%p\n", Op, WalkState)); - } - - ObjectType = WalkState->OpInfo->ObjectType; - - /* - * Get the Node/name from the earlier lookup - * (It was saved in the *op structure) - */ - Node = Op->Common.Node; - - /* - * Put the Node on the object stack (Contains the ACPI Name of - * this object) - */ - WalkState->Operands[0] = (void *) Node; - WalkState->NumOperands = 1; - - /* Pop the scope stack */ - - if (AcpiNsOpensScope (ObjectType) && - (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", - AcpiUtGetTypeName (ObjectType), Op)); - - Status = AcpiDsScopeStackPop (WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } - - /* - * Named operations are as follows: - * - * AML_ALIAS - * AML_BANKFIELD - * AML_CREATEBITFIELD - * AML_CREATEBYTEFIELD - * AML_CREATEDWORDFIELD - * AML_CREATEFIELD - * AML_CREATEQWORDFIELD - * AML_CREATEWORDFIELD - * AML_DATA_REGION - * AML_DEVICE - * AML_EVENT - * AML_FIELD - * AML_INDEXFIELD - * AML_METHOD - * AML_METHODCALL - * AML_MUTEX - * AML_NAME - * AML_NAMEDFIELD - * AML_OPREGION - * AML_POWERRES - * AML_PROCESSOR - * AML_SCOPE - * AML_THERMALZONE - */ - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", - AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); - - /* Decode the opcode */ - - Arg = Op->Common.Value.Arg; - - switch (WalkState->OpInfo->Type) - { -#ifndef ACPI_NO_METHOD_EXECUTION - - case AML_TYPE_CREATE_FIELD: - /* - * Create the field object, but the field buffer and index must - * be evaluated later during the execution phase - */ - Status = AcpiDsCreateBufferField (Op, WalkState); - break; - - - case AML_TYPE_NAMED_FIELD: - /* - * If we are executing a method, initialize the field - */ - if (WalkState->MethodNode) - { - Status = AcpiDsInitFieldObjects (Op, WalkState); - } - - switch (Op->Common.AmlOpcode) - { - case AML_INDEX_FIELD_OP: - - Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, - WalkState); - break; - - case AML_BANK_FIELD_OP: - - Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); - break; - - case AML_FIELD_OP: - - Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); - break; - - default: - /* All NAMED_FIELD opcodes must be handled above */ - break; - } - break; - - - case AML_TYPE_NAMED_SIMPLE: - - Status = AcpiDsCreateOperands (WalkState, Arg); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - switch (Op->Common.AmlOpcode) - { - case AML_PROCESSOR_OP: - - Status = AcpiExCreateProcessor (WalkState); - break; - - case AML_POWER_RES_OP: - - Status = AcpiExCreatePowerResource (WalkState); - break; - - case AML_MUTEX_OP: - - Status = AcpiExCreateMutex (WalkState); - break; - - case AML_EVENT_OP: - - Status = AcpiExCreateEvent (WalkState); - break; - - - case AML_ALIAS_OP: - - Status = AcpiExCreateAlias (WalkState); - break; - - default: - /* Unknown opcode */ - - Status = AE_OK; - goto Cleanup; - } - - /* Delete operands */ - - for (i = 1; i < WalkState->NumOperands; i++) - { - AcpiUtRemoveReference (WalkState->Operands[i]); - WalkState->Operands[i] = NULL; - } - - break; -#endif /* ACPI_NO_METHOD_EXECUTION */ - - case AML_TYPE_NAMED_COMPLEX: - - switch (Op->Common.AmlOpcode) - { -#ifndef ACPI_NO_METHOD_EXECUTION - case AML_REGION_OP: - case AML_DATA_REGION_OP: - - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - RegionSpace = (ACPI_ADR_SPACE_TYPE) - ((Op->Common.Value.Arg)->Common.Value.Integer); - } - else - { - RegionSpace = REGION_DATA_TABLE; - } - - /* - * If we are executing a method, initialize the region - */ - if (WalkState->MethodNode) - { - Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - RegionSpace, WalkState); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - - /* - * The OpRegion is not fully parsed at this time. Only valid - * argument is the SpaceId. (We must save the address of the - * AML of the address and length operands) - */ - - /* - * If we have a valid region, initialize it - * Namespace is NOT locked at this point. - * - * TBD: need to unlock interpreter if it is locked, in order - * to allow _REG methods to be run. - */ - Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), - FALSE); - if (ACPI_FAILURE (Status)) - { - /* - * If AE_NOT_EXIST is returned, it is not fatal - * because many regions get created before a handler - * is installed for said region. - */ - if (AE_NOT_EXIST == Status) - { - Status = AE_OK; - } - } - break; - - - case AML_NAME_OP: - - Status = AcpiDsCreateNode (WalkState, Node, Op); - break; - - - case AML_METHOD_OP: - /* - * MethodOp PkgLength NameString MethodFlags TermList - * - * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing - * of invocations of the method (need to know the number of - * arguments.) - */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "LOADING-Method: State=%p Op=%p NamedObj=%p\n", - WalkState, Op, Op->Named.Node)); - - if (!AcpiNsGetAttachedObject (Op->Named.Node)) - { - WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); - WalkState->NumOperands = 1; - - Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); - if (ACPI_SUCCESS (Status)) - { - Status = AcpiExCreateMethod (Op->Named.Data, - Op->Named.Length, WalkState); - } - WalkState->Operands[0] = NULL; - WalkState->NumOperands = 0; - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - break; - -#endif /* ACPI_NO_METHOD_EXECUTION */ - - default: - /* All NAMED_COMPLEX opcodes must be handled above */ - break; - } - break; - - - case AML_CLASS_INTERNAL: - - /* case AML_INT_NAMEPATH_OP: */ - break; - - - case AML_CLASS_METHOD_CALL: - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", - WalkState, Op, Node)); - - /* - * Lookup the method name and save the Node - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &(NewNode)); - if (ACPI_SUCCESS (Status)) - { - /* - * Make sure that what we found is indeed a method - * We didn't search for a method on purpose, to see if the name - * would resolve - */ - if (NewNode->Type != ACPI_TYPE_METHOD) - { - Status = AE_AML_OPERAND_TYPE; - } - - /* We could put the returned object (Node) on the object stack for - * later, but for now, we will put it in the "op" object that the - * parser uses, so we can get it again at the end of this scope - */ - Op->Common.Node = NewNode; - } - else - { - ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); - } - break; - - - default: - break; - } - -Cleanup: - - /* Remove the Node pushed at the very beginning */ - - WalkState->Operands[0] = NULL; - WalkState->NumOperands = 0; - return_ACPI_STATUS (Status); -} - - diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dswload.c b/sys/contrib/dev/acpica-unix/dispatcher/dswload2.c similarity index 57% copy from sys/contrib/dev/acpica-unix/dispatcher/dswload.c copy to sys/contrib/dev/acpica-unix/dispatcher/dswload2.c index d5a642ce70..340f330893 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dswload.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dswload2.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dswload - Dispatcher namespace load callbacks + * Module Name: dswload2 - Dispatcher second pass namespace load callbacks * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,7 +113,7 @@ * *****************************************************************************/ -#define __DSWLOAD_C__ +#define __DSWLOAD2_C__ #include "acpi.h" #include "accommon.h" @@ -124,502 +124,8 @@ #include "acnamesp.h" #include "acevents.h" -#ifdef ACPI_ASL_COMPILER -#include "acdisasm.h" -#endif - #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswload") - - -/******************************************************************************* - * - * FUNCTION: AcpiDsInitCallbacks - * - * PARAMETERS: WalkState - Current state of the parse tree walk - * PassNumber - 1, 2, or 3 - * - * RETURN: Status - * - * DESCRIPTION: Init walk state callbacks - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsInitCallbacks ( - ACPI_WALK_STATE *WalkState, - UINT32 PassNumber) -{ - - switch (PassNumber) - { - case 1: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | - ACPI_PARSE_DELETE_TREE; - WalkState->DescendingCallback = AcpiDsLoad1BeginOp; - WalkState->AscendingCallback = AcpiDsLoad1EndOp; - break; - - case 2: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | - ACPI_PARSE_DELETE_TREE; - WalkState->DescendingCallback = AcpiDsLoad2BeginOp; - WalkState->AscendingCallback = AcpiDsLoad2EndOp; - break; - - case 3: -#ifndef ACPI_NO_METHOD_EXECUTION - WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | - ACPI_PARSE_DELETE_TREE; - WalkState->DescendingCallback = AcpiDsExecBeginOp; - WalkState->AscendingCallback = AcpiDsExecEndOp; -#endif - break; - - default: - return (AE_BAD_PARAMETER); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsLoad1BeginOp - * - * PARAMETERS: WalkState - Current state of the parse tree walk - * OutOp - Where to return op if a new one is created - * - * RETURN: Status - * - * DESCRIPTION: Descending callback used during the loading of ACPI tables. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsLoad1BeginOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT **OutOp) -{ - ACPI_PARSE_OBJECT *Op; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_OBJECT_TYPE ObjectType; - char *Path; - UINT32 Flags; - - - ACPI_FUNCTION_TRACE (DsLoad1BeginOp); - - - Op = WalkState->Op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); - - /* We are only interested in opcodes that have an associated name */ - - if (Op) - { - if (!(WalkState->OpInfo->Flags & AML_NAMED)) - { - *OutOp = Op; - return_ACPI_STATUS (AE_OK); - } - - /* Check if this object has already been installed in the namespace */ - - if (Op->Common.Node) - { - *OutOp = Op; - return_ACPI_STATUS (AE_OK); - } - } - - Path = AcpiPsGetNextNamestring (&WalkState->ParserState); - - /* Map the raw opcode into an internal object type */ - - ObjectType = WalkState->OpInfo->ObjectType; - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); - - switch (WalkState->Opcode) - { - case AML_SCOPE_OP: - - /* - * The target name of the Scope() operator must exist at this point so - * that we can actually open the scope to enter new names underneath it. - * Allow search-to-root for single namesegs. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); -#ifdef ACPI_ASL_COMPILER - if (Status == AE_NOT_FOUND) - { - /* - * Table disassembly: - * Target of Scope() not found. Generate an External for it, and - * insert the name into the namespace. - */ - AcpiDmAddToExternalList (Path, ACPI_TYPE_DEVICE, 0); - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, - WalkState, &Node); - } -#endif - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR_NAMESPACE (Path, Status); - return_ACPI_STATUS (Status); - } - - /* - * Check to make sure that the target is - * one of the opcodes that actually opens a scope - */ - switch (Node->Type) - { - case ACPI_TYPE_ANY: - case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - - /* These are acceptable types */ - break; - - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - /* - * These types we will allow, but we will change the type. This - * enables some existing code of the form: - * - * Name (DEB, 0) - * Scope (DEB) { ... } - * - * Note: silently change the type here. On the second pass, we will report - * a warning - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", - Path, AcpiUtGetTypeName (Node->Type))); - - Node->Type = ACPI_TYPE_ANY; - WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; - break; - - default: - - /* All other types are an error */ - - ACPI_ERROR ((AE_INFO, - "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", - AcpiUtGetTypeName (Node->Type), Path)); - - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - break; - - - default: - /* - * For all other named opcodes, we will enter the name into - * the namespace. - * - * Setup the search flags. - * Since we are entering a name into the namespace, we do not want to - * enable the search-to-root upsearch. - * - * There are only two conditions where it is acceptable that the name - * already exists: - * 1) the Scope() operator can reopen a scoping object that was - * previously defined (Scope, Method, Device, etc.) - * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, - * BufferField, or Package), the name of the object is already - * in the namespace. - */ - if (WalkState->DeferredNode) - { - /* This name is already in the namespace, get the node */ - - Node = WalkState->DeferredNode; - Status = AE_OK; - break; - } - - /* - * If we are executing a method, do not create any namespace objects - * during the load phase, only during execution. - */ - if (WalkState->MethodNode) - { - Node = NULL; - Status = AE_OK; - break; - } - - Flags = ACPI_NS_NO_UPSEARCH; - if ((WalkState->Opcode != AML_SCOPE_OP) && - (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) - { - Flags |= ACPI_NS_ERROR_IF_FOUND; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", - AcpiUtGetTypeName (ObjectType))); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[%s] Both Find or Create allowed\n", - AcpiUtGetTypeName (ObjectType))); - } - - /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that - * involve arguments to the opcode must be created as we go back up the - * parse tree later. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* The name already exists in this scope */ - - if (Node->Flags & ANOBJ_IS_EXTERNAL) - { - /* - * Allow one create on an object or segment that was - * previously declared External - */ - Node->Flags &= ~ANOBJ_IS_EXTERNAL; - Node->Type = (UINT8) ObjectType; - - /* Just retyped a node, probably will need to open a scope */ - - if (AcpiNsOpensScope (ObjectType)) - { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - Status = AE_OK; - } - } - - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR_NAMESPACE (Path, Status); - return_ACPI_STATUS (Status); - } - } - break; - } - - /* Common exit */ - - if (!Op) - { - /* Create a new op */ - - Op = AcpiPsAllocOp (WalkState->Opcode); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - } - - /* Initialize the op */ - -#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) - Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); -#endif - - if (Node) - { - /* - * Put the Node in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - Op->Common.Node = Node; - Op->Named.Name = Node->Name.Integer; - } - - AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); - *OutOp = Op; - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsLoad1EndOp - * - * PARAMETERS: WalkState - Current state of the parse tree walk - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback used during the loading of the namespace, - * both control methods and everything else. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsLoad1EndOp ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_PARSE_OBJECT *Op; - ACPI_OBJECT_TYPE ObjectType; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (DsLoad1EndOp); - - - Op = WalkState->Op; - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); - - /* We are only interested in opcodes that have an associated name */ - - if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the object type to determine if we should pop the scope */ - - ObjectType = WalkState->OpInfo->ObjectType; - -#ifndef ACPI_NO_METHOD_EXECUTION - if (WalkState->OpInfo->Flags & AML_FIELD) - { - /* - * If we are executing a method, do not create any namespace objects - * during the load phase, only during execution. - */ - if (!WalkState->MethodNode) - { - if (WalkState->Opcode == AML_FIELD_OP || - WalkState->Opcode == AML_BANK_FIELD_OP || - WalkState->Opcode == AML_INDEX_FIELD_OP) - { - Status = AcpiDsInitFieldObjects (Op, WalkState); - } - } - return_ACPI_STATUS (Status); - } - - /* - * If we are executing a method, do not create any namespace objects - * during the load phase, only during execution. - */ - if (!WalkState->MethodNode) - { - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), - WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) - { - Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - REGION_DATA_TABLE, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } -#endif - - if (Op->Common.AmlOpcode == AML_NAME_OP) - { - /* For Name opcode, get the object type from the argument */ - - if (Op->Common.Value.Arg) - { - ObjectType = (AcpiPsGetOpcodeInfo ( - (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; - - /* Set node type if we have a namespace node */ - - if (Op->Common.Node) - { - Op->Common.Node->Type = (UINT8) ObjectType; - } - } - } - - /* - * If we are executing a method, do not create any namespace objects - * during the load phase, only during execution. - */ - if (!WalkState->MethodNode) - { - if (Op->Common.AmlOpcode == AML_METHOD_OP) - { - /* - * MethodOp PkgLength NameString MethodFlags TermList - * - * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing - * of invocations of the method (need to know the number of - * arguments.) - */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "LOADING-Method: State=%p Op=%p NamedObj=%p\n", - WalkState, Op, Op->Named.Node)); - - if (!AcpiNsGetAttachedObject (Op->Named.Node)) - { - WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); - WalkState->NumOperands = 1; - - Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); - if (ACPI_SUCCESS (Status)) - { - Status = AcpiExCreateMethod (Op->Named.Data, - Op->Named.Length, WalkState); - } - - WalkState->Operands[0] = NULL; - WalkState->NumOperands = 0; - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - } - - /* Pop the scope stack (only if loading a table) */ - - if (!WalkState->MethodNode && - AcpiNsOpensScope (ObjectType)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", - AcpiUtGetTypeName (ObjectType), Op)); - - Status = AcpiDsScopeStackPop (WalkState); - } - - return_ACPI_STATUS (Status); -} + ACPI_MODULE_NAME ("dswload2") /******************************************************************************* @@ -672,20 +178,6 @@ AcpiDsLoad2BeginOp ( (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || (!(WalkState->OpInfo->Flags & AML_NAMED))) { -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Begin/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecBeginOp (WalkState, OutOp); - return_ACPI_STATUS (Status); - } -#endif return_ACPI_STATUS (AE_OK); } @@ -746,29 +238,45 @@ AcpiDsLoad2BeginOp ( break; case AML_SCOPE_OP: - /* - * The Path is an object reference to an existing object. - * Don't enter the name into the namespace, but look it up - * for use later. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); - if (ACPI_FAILURE (Status)) + + /* Special case for Scope(\) -> refers to the Root node */ + + if (Op && (Op->Named.Node == AcpiGbl_RootNode)) { -#ifdef ACPI_ASL_COMPILER - if (Status == AE_NOT_FOUND) + Node = Op->Named.Node; + + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) { - Status = AE_OK; + return_ACPI_STATUS (Status); } - else + } + else + { + /* + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (BufferPtr, Status); - } +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + Status = AE_OK; + } + else + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + } #else - ACPI_ERROR_NAMESPACE (BufferPtr, Status); + ACPI_ERROR_NAMESPACE (BufferPtr, Status); #endif - return_ACPI_STATUS (Status); + return_ACPI_STATUS (Status); + } } /* @@ -792,15 +300,16 @@ AcpiDsLoad2BeginOp ( case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This - * enables some existing code of the form: + * These types we will allow, but we will change the type. + * This enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } */ ACPI_WARNING ((AE_INFO, - "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", - BufferPtr, AcpiUtGetTypeName (Node->Type))); + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; @@ -811,8 +320,9 @@ AcpiDsLoad2BeginOp ( /* All other types are an error */ ACPI_ERROR ((AE_INFO, - "Invalid type (%s) for target of Scope operator [%4.4s]", - AcpiUtGetTypeName (Node->Type), BufferPtr)); + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); return (AE_AML_OPERAND_TYPE); } @@ -862,7 +372,12 @@ AcpiDsLoad2BeginOp ( { /* Execution mode, node cannot already exist, node is temporary */ - Flags |= (ACPI_NS_ERROR_IF_FOUND | ACPI_NS_TEMPORARY); + Flags |= ACPI_NS_ERROR_IF_FOUND; + + if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } } /* Add new entry or lookup existing entry */ @@ -952,24 +467,6 @@ AcpiDsLoad2EndOp ( if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) { -#ifndef ACPI_NO_METHOD_EXECUTION -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - /* No namespace object. Executable opcode? */ - - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "End/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, - WalkState->OpInfo->Flags)); - - /* Executing a type1 or type2 opcode outside of a method */ - - Status = AcpiDsExecEndOp (WalkState); - return_ACPI_STATUS (Status); - } -#endif -#endif return_ACPI_STATUS (AE_OK); } @@ -1165,33 +662,40 @@ AcpiDsLoad2EndOp ( } /* - * If we are executing a method, initialize the region + * The OpRegion is not fully parsed at this time. The only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) + * + * If we have a valid region, initialize it. The namespace is + * unlocked at this point. + * + * Need to unlock interpreter if it is locked (if we are running + * a control method), in order to allow _REG methods to be run + * during AcpiEvInitializeRegion. */ if (WalkState->MethodNode) { + /* + * Executing a method: initialize the region and unlock + * the interpreter + */ Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, RegionSpace, WalkState); if (ACPI_FAILURE (Status)) { return (Status); } - } - /* - * 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) - */ + AcpiExExitInterpreter (); + } - /* - * If we have a valid region, initialize it - * Namespace is NOT locked at this point. - * - * TBD: need to unlock interpreter if it is locked, in order - * to allow _REG methods to be run. - */ Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); + if (WalkState->MethodNode) + { + AcpiExEnterInterpreter (); + } + if (ACPI_FAILURE (Status)) { /* @@ -1312,5 +816,3 @@ Cleanup: WalkState->NumOperands = 0; return_ACPI_STATUS (Status); } - - diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dswscope.c b/sys/contrib/dev/acpica-unix/dispatcher/dswscope.c index 023f9ef666..b95c42746c 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dswscope.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dswscope.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/dispatcher/dswstate.c b/sys/contrib/dev/acpica-unix/dispatcher/dswstate.c index f0962bf53f..07ed6d4d71 100644 --- a/sys/contrib/dev/acpica-unix/dispatcher/dswstate.c +++ b/sys/contrib/dev/acpica-unix/dispatcher/dswstate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -277,7 +277,7 @@ AcpiDsResultPush ( if (!Object) { ACPI_ERROR ((AE_INFO, - "Null Object! Obj=%p State=%p Num=%X", + "Null Object! Obj=%p State=%p Num=%u", Object, WalkState, WalkState->ResultCount)); return (AE_BAD_PARAMETER); } @@ -323,7 +323,7 @@ AcpiDsResultStackPush ( if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > ACPI_RESULTS_OBJ_NUM_MAX) { - ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%X", + ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%u", WalkState, WalkState->ResultSize)); return (AE_STACK_OVERFLOW); } @@ -426,7 +426,7 @@ AcpiDsObjStackPush ( if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) { ACPI_ERROR ((AE_INFO, - "Object stack overflow! Obj=%p State=%p #Ops=%X", + "Object stack overflow! Obj=%p State=%p #Ops=%u", Object, WalkState, WalkState->NumOperands)); return (AE_STACK_OVERFLOW); } @@ -480,7 +480,7 @@ AcpiDsObjStackPop ( if (WalkState->NumOperands == 0) { ACPI_ERROR ((AE_INFO, - "Object stack underflow! Count=%X State=%p #Ops=%X", + "Object stack underflow! Count=%X State=%p #Ops=%u", PopCount, WalkState, WalkState->NumOperands)); return (AE_STACK_UNDERFLOW); } @@ -491,7 +491,7 @@ AcpiDsObjStackPop ( WalkState->Operands [WalkState->NumOperands] = NULL; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%u\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_OK); diff --git a/sys/contrib/dev/acpica-unix/events/evevent.c b/sys/contrib/dev/acpica-unix/events/evevent.c index 16f40271fc..a85588f105 100644 --- a/sys/contrib/dev/acpica-unix/events/evevent.c +++ b/sys/contrib/dev/acpica-unix/events/evevent.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -178,54 +178,6 @@ AcpiEvInitializeEvents ( } -/******************************************************************************* - * - * FUNCTION: AcpiEvInstallFadtGpes - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks - * (0 and 1). This causes the _PRW methods to be run, so the HW - * must be fully initialized at this point, including global lock - * support. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvInstallFadtGpes ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvInstallFadtGpes); - - - /* Namespace must be locked */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* FADT GPE Block 0 */ - - (void) AcpiEvInitializeGpeBlock ( - AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[0]); - - /* FADT GPE Block 1 */ - - (void) AcpiEvInitializeGpeBlock ( - AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[1]); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_OK); -} - - /******************************************************************************* * * FUNCTION: AcpiEvInstallXruptHandlers @@ -366,9 +318,17 @@ AcpiEvFixedEventDetect ( if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) { - /* Found an active (signalled) event */ - + /* + * Found an active (signalled) event. Invoke global event + * handler if present. + */ AcpiFixedEventCount[i]++; + if (AcpiGbl_GlobalEventHandler) + { + AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_FIXED, NULL, + i, AcpiGbl_GlobalEventHandlerContext); + } + IntStatus |= AcpiEvFixedEventDispatch (i); } } @@ -415,7 +375,7 @@ AcpiEvFixedEventDispatch ( ACPI_DISABLE_EVENT); ACPI_ERROR ((AE_INFO, - "No installed handler for fixed event [%08X]", + "No installed handler for fixed event [0x%08X]", Event)); return (ACPI_INTERRUPT_NOT_HANDLED); diff --git a/sys/contrib/dev/acpica-unix/events/evgpe.c b/sys/contrib/dev/acpica-unix/events/evgpe.c index 95cb9fa7ea..59e5d55879 100644 --- a/sys/contrib/dev/acpica-unix/events/evgpe.c +++ b/sys/contrib/dev/acpica-unix/events/evgpe.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -134,272 +134,238 @@ AcpiEvAsynchEnableGpe ( /******************************************************************************* * - * FUNCTION: AcpiEvSetGpeType + * FUNCTION: AcpiEvUpdateGpeEnableMask * - * PARAMETERS: GpeEventInfo - GPE to set - * Type - New type + * PARAMETERS: GpeEventInfo - GPE to update * * RETURN: Status * - * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * DESCRIPTION: Updates GPE register enable mask based upon whether there are + * runtime references to this GPE * ******************************************************************************/ ACPI_STATUS -AcpiEvSetGpeType ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - UINT8 Type) +AcpiEvUpdateGpeEnableMask ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) { - ACPI_STATUS Status; - + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 RegisterBit; - ACPI_FUNCTION_TRACE (EvSetGpeType); + ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMask); - /* Validate type and update register enable masks */ - switch (Type) + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) { - case ACPI_GPE_TYPE_WAKE: - case ACPI_GPE_TYPE_RUNTIME: - case ACPI_GPE_TYPE_WAKE_RUN: - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_NOT_EXIST); } - /* Disable the GPE if currently enabled */ + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); - Status = AcpiEvDisableGpe (GpeEventInfo); + /* Clear the run bit up front */ - /* Clear the type bits and insert the new Type */ + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); - GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; - GpeEventInfo->Flags |= Type; - return_ACPI_STATUS (Status); + /* Set the mask bit only if there are references to this GPE */ + + if (GpeEventInfo->RuntimeCount) + { + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit); + } + + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiEvUpdateGpeEnableMasks + * FUNCTION: AcpiEvEnableGpe * - * PARAMETERS: GpeEventInfo - GPE to update - * Type - What to do: ACPI_GPE_DISABLE or - * ACPI_GPE_ENABLE + * PARAMETERS: GpeEventInfo - GPE to enable * * RETURN: Status * - * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * DESCRIPTION: Clear a GPE of stale events and enable it. * ******************************************************************************/ ACPI_STATUS -AcpiEvUpdateGpeEnableMasks ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - UINT8 Type) +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) { - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - UINT8 RegisterBit; + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMasks); + ACPI_FUNCTION_TRACE (EvEnableGpe); - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) + /* + * We will only allow a GPE to be enabled if it has either an associated + * method (_Lxx/_Exx) or a handler, or is using the implicit notify + * feature. Otherwise, the GPE will be immediately disabled by + * AcpiEvGpeDispatch the first time it fires. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_NONE) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS (AE_NO_HANDLER); } - RegisterBit = (UINT8) - (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); - - /* 1) Disable case. Simply clear all enable bits */ + /* Clear the GPE (of stale events) */ - if (Type == ACPI_GPE_DISABLE) + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) { - ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); - ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } - /* 2) Enable case. Set/Clear the appropriate enable bits */ - - switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) - { - case ACPI_GPE_TYPE_WAKE: - ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); - ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); - break; - - case ACPI_GPE_TYPE_RUNTIME: - ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); - ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); - break; - - case ACPI_GPE_TYPE_WAKE_RUN: - ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); - ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); - break; + /* Enable the requested GPE */ - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - return_ACPI_STATUS (AE_OK); + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiEvEnableGpe + * FUNCTION: AcpiEvAddGpeReference * - * PARAMETERS: GpeEventInfo - GPE to enable - * WriteToHardware - Enable now, or just mark data structs - * (WAKE GPEs should be deferred) + * PARAMETERS: GpeEventInfo - Add a reference to this GPE * * RETURN: Status * - * DESCRIPTION: Enable a GPE based on the GPE type + * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is + * hardware-enabled. * ******************************************************************************/ ACPI_STATUS -AcpiEvEnableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - BOOLEAN WriteToHardware) +AcpiEvAddGpeReference ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) { - ACPI_STATUS Status; - + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE (EvEnableGpe); + ACPI_FUNCTION_TRACE (EvAddGpeReference); - /* Make sure HW enable masks are updated */ - Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); - if (ACPI_FAILURE (Status)) + if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX) { - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_LIMIT); } - /* Mark wake-enabled or HW enable, or both */ - - switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + GpeEventInfo->RuntimeCount++; + if (GpeEventInfo->RuntimeCount == 1) { - case ACPI_GPE_TYPE_WAKE: - - ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); - break; - - case ACPI_GPE_TYPE_WAKE_RUN: - - ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); - - /*lint -fallthrough */ - - case ACPI_GPE_TYPE_RUNTIME: - - ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + /* Enable on first reference */ - if (WriteToHardware) + Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo); + if (ACPI_SUCCESS (Status)) { - /* Clear the GPE (of stale events), then enable it */ - - Status = AcpiHwClearGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Enable the requested runtime GPE */ - - Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + Status = AcpiEvEnableGpe (GpeEventInfo); } - break; - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + if (ACPI_FAILURE (Status)) + { + GpeEventInfo->RuntimeCount--; + } } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiEvDisableGpe + * FUNCTION: AcpiEvRemoveGpeReference * - * PARAMETERS: GpeEventInfo - GPE to disable + * PARAMETERS: GpeEventInfo - Remove a reference to this GPE * * RETURN: Status * - * DESCRIPTION: Disable a GPE based on the GPE type + * DESCRIPTION: Remove a reference to a GPE. When the last reference is + * removed, the GPE is hardware-disabled. * ******************************************************************************/ ACPI_STATUS -AcpiEvDisableGpe ( +AcpiEvRemoveGpeReference ( ACPI_GPE_EVENT_INFO *GpeEventInfo) { - ACPI_STATUS Status; - + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE (EvDisableGpe); + ACPI_FUNCTION_TRACE (EvRemoveGpeReference); - /* - * Note: Always disable the GPE, even if we think that that it is already - * disabled. It is possible that the AML or some other code has enabled - * the GPE behind our back. - */ - /* Make sure HW enable masks are updated */ - - Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); - if (ACPI_FAILURE (Status)) + if (!GpeEventInfo->RuntimeCount) { - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_LIMIT); } - /* Clear the appropriate enabled flags for this GPE */ - - switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + GpeEventInfo->RuntimeCount--; + if (!GpeEventInfo->RuntimeCount) { - case ACPI_GPE_TYPE_WAKE: - - ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); - break; + /* Disable on last reference */ - case ACPI_GPE_TYPE_WAKE_RUN: + Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + } - ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + if (ACPI_FAILURE (Status)) + { + GpeEventInfo->RuntimeCount++; + } + } - /*lint -fallthrough */ + return_ACPI_STATUS (Status); +} - case ACPI_GPE_TYPE_RUNTIME: - /* Disable the requested runtime GPE */ +/******************************************************************************* + * + * FUNCTION: AcpiEvLowGetGpeInfo + * + * PARAMETERS: GpeNumber - Raw GPE number + * GpeBlock - A GPE info block + * + * RETURN: A GPE EventInfo struct. NULL if not a valid GPE (The GpeNumber + * is not within the specified GPE block) + * + * DESCRIPTION: Returns the EventInfo struct associated with this GPE. This is + * the low-level implementation of EvGetGpeEventInfo. + * + ******************************************************************************/ - ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); - break; +ACPI_GPE_EVENT_INFO * +AcpiEvLowGetGpeInfo ( + UINT32 GpeNumber, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + UINT32 GpeIndex; - default: - break; - } /* - * Always H/W disable this GPE, even if we don't know the GPE type. - * Simply clear the enable bit for this particular GPE, but do not - * write out the current GPE enable mask since this may inadvertently - * enable GPEs too early. An example is a rogue GPE that has arrived - * during ACPICA initialization - possibly because AML or other code - * has enabled the GPE. + * Validate that the GpeNumber is within the specified GpeBlock. + * (Two steps) */ - Status = AcpiHwLowDisableGpe (GpeEventInfo); - return_ACPI_STATUS (Status); + if (!GpeBlock || + (GpeNumber < GpeBlock->BlockBaseNumber)) + { + return (NULL); + } + + GpeIndex = GpeNumber - GpeBlock->BlockBaseNumber; + if (GpeIndex >= GpeBlock->GpeCount) + { + return (NULL); + } + + return (&GpeBlock->EventInfo[GpeIndex]); } @@ -426,14 +392,14 @@ AcpiEvGetGpeEventInfo ( UINT32 GpeNumber) { ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_EVENT_INFO *GpeInfo; UINT32 i; ACPI_FUNCTION_ENTRY (); - /* A NULL GpeBlock means use the FADT-defined GPE block(s) */ + /* A NULL GpeDevice means use the FADT-defined GPE block(s) */ if (!GpeDevice) { @@ -441,16 +407,11 @@ AcpiEvGetGpeEventInfo ( for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { - GpeBlock = AcpiGbl_GpeFadtBlocks[i]; - if (GpeBlock) + GpeInfo = AcpiEvLowGetGpeInfo (GpeNumber, + AcpiGbl_GpeFadtBlocks[i]); + if (GpeInfo) { - if ((GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + - (GpeBlock->RegisterCount * 8))) - { - return (&GpeBlock->EventInfo[GpeNumber - - GpeBlock->BlockBaseNumber]); - } + return (GpeInfo); } } @@ -468,15 +429,7 @@ AcpiEvGetGpeEventInfo ( return (NULL); } - GpeBlock = ObjDesc->Device.GpeBlock; - - if ((GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) - { - return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); - } - - return (NULL); + return (AcpiEvLowGetGpeInfo (GpeNumber, ObjDesc->Device.GpeBlock)); } @@ -541,9 +494,19 @@ AcpiEvGpeDetect ( GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + /* + * Optimization: If there are no GPEs enabled within this + * register, we can safely ignore the entire register. + */ + if (!(GpeRegisterInfo->EnableForRun | + GpeRegisterInfo->EnableForWake)) + { + continue; + } + /* Read the Status Register */ - Status = AcpiRead (&StatusReg, &GpeRegisterInfo->StatusAddress); + Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -551,14 +514,14 @@ AcpiEvGpeDetect ( /* Read the Enable Register */ - Status = AcpiRead (&EnableReg, &GpeRegisterInfo->EnableAddress); + Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n", GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); /* Check if there is anything active at all in this register */ @@ -583,7 +546,7 @@ AcpiEvGpeDetect ( * Found an active GPE. Dispatch the event to a handler * or method. */ - IntStatus |= AcpiEvGpeDispatch ( + IntStatus |= AcpiEvGpeDispatch (GpeBlock->Node, &GpeBlock->EventInfo[((ACPI_SIZE) i * ACPI_GPE_REGISTER_WIDTH) + j], j + GpeRegisterInfo->BaseGpeNumber); @@ -654,10 +617,6 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } - /* Set the GPE flags for return to enabled state */ - - (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); - /* * Take a snapshot of the GPE info for this level - we copy the info to * prevent a race condition with RemoveHandler/RemoveBlock. @@ -671,13 +630,27 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } - /* - * Must check for control method type dispatch one more time to avoid a - * race with EvGpeInstallHandler - */ - if ((LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_METHOD) + /* Do the correct dispatch - normal method or implicit notify */ + + switch (LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { + case ACPI_GPE_DISPATCH_NOTIFY: + + /* + * Implicit notify. + * Dispatch a DEVICE_WAKE notify to the appropriate handler. + * NOTE: the request is queued for execution after this method + * completes. The notify handlers are NOT invoked synchronously + * from this thread -- because handlers may in turn run other + * control methods. + */ + Status = AcpiEvQueueNotifyRequest ( + LocalGpeEventInfo->Dispatch.DeviceNode, + ACPI_NOTIFY_DEVICE_WAKE); + break; + + case ACPI_GPE_DISPATCH_METHOD: + /* Allocate the evaluation information block */ Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); @@ -688,8 +661,8 @@ AcpiEvAsynchExecuteGpeMethod ( else { /* - * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx - * control method that corresponds to this GPE + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the + * _Lxx/_Exx control method that corresponds to this GPE */ Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode; Info->Flags = ACPI_IGNORE_RETURN_VALUE; @@ -704,6 +677,11 @@ AcpiEvAsynchExecuteGpeMethod ( "while evaluating GPE method [%4.4s]", AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode))); } + + break; + + default: + return_VOID; /* Should never happen */ } /* Defer enabling of GPE until all notify handlers are done */ @@ -723,6 +701,7 @@ AcpiEvAsynchExecuteGpeMethod ( * FUNCTION: AcpiEvAsynchEnableGpe * * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * Callback from AcpiOsExecute * * RETURN: None * @@ -736,6 +715,32 @@ AcpiEvAsynchEnableGpe ( void *Context) { ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + + + (void) AcpiEvFinishGpe (GpeEventInfo); + + ACPI_FREE (GpeEventInfo); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFinishGpe + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * + * RETURN: Status + * + * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution + * of a GPE method or a synchronous or asynchronous GPE handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvFinishGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ ACPI_STATUS Status; @@ -743,23 +748,23 @@ AcpiEvAsynchEnableGpe ( ACPI_GPE_LEVEL_TRIGGERED) { /* - * GPE is level-triggered, we clear the GPE status bit after handling - * the event. + * GPE is level-triggered, we clear the GPE status bit after + * handling the event. */ Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { - goto Exit; + return (Status); } } - /* Enable this GPE */ - - (void) AcpiHwWriteGpeEnableReg (GpeEventInfo); - -Exit: - ACPI_FREE (GpeEventInfo); - return; + /* + * Enable this GPE, conditionally. This means that the GPE will + * only be physically enabled if the EnableForRun bit is set + * in the EventInfo. + */ + (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_CONDITIONAL_ENABLE); + return (AE_OK); } @@ -767,8 +772,9 @@ Exit: * * FUNCTION: AcpiEvGpeDispatch * - * PARAMETERS: GpeEventInfo - Info for this GPE - * GpeNumber - Number relative to the parent GPE block + * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 + * GpeEventInfo - Info for this GPE + * GpeNumber - Number relative to the parent GPE block * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * @@ -781,16 +787,25 @@ Exit: UINT32 AcpiEvGpeDispatch ( + ACPI_NAMESPACE_NODE *GpeDevice, ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 GpeNumber) { ACPI_STATUS Status; + UINT32 ReturnValue; ACPI_FUNCTION_TRACE (EvGpeDispatch); + /* Invoke global event handler if present */ + AcpiGpeCount++; + if (AcpiGbl_GlobalEventHandler) + { + AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE, GpeDevice, + GpeNumber, AcpiGbl_GlobalEventHandlerContext); + } /* * If edge-triggered, clear the GPE status bit now. Note that @@ -803,58 +818,55 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to clear GPE[%2X]", GpeNumber)); + "Unable to clear GPE%02X", GpeNumber)); return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } } /* - * Dispatch the GPE to either an installed handler, or the control method - * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke - * it and do not attempt to run the method. If there is neither a handler - * nor a method, we disable this GPE to prevent further such pointless - * events from firing. + * Always disable the GPE so that it does not keep firing before + * any asynchronous activity completes (either from the execution + * of a GPE method or an asynchronous GPE handler.) + * + * If there is no handler or method to run, just disable the + * GPE and leave it disabled permanently to prevent further such + * pointless events from firing. + */ + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE%02X", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* + * Dispatch the GPE to either an installed handler or the control + * method associated with this GPE (_Lxx or _Exx). If a handler + * exists, we invoke it and do not attempt to run the method. + * If there is neither a handler nor a method, leave the GPE + * disabled. */ switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { case ACPI_GPE_DISPATCH_HANDLER: - /* - * Invoke the installed handler (at interrupt level) - * Ignore return status for now. - * TBD: leave GPE disabled on error? - */ - (void) GpeEventInfo->Dispatch.Handler->Address ( - GpeEventInfo->Dispatch.Handler->Context); + /* Invoke the installed handler (at interrupt level) */ + + ReturnValue = GpeEventInfo->Dispatch.Handler->Address ( + GpeDevice, GpeNumber, + GpeEventInfo->Dispatch.Handler->Context); - /* It is now safe to clear level-triggered events. */ + /* If requested, clear (if level-triggered) and reenable the GPE */ - if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == - ACPI_GPE_LEVEL_TRIGGERED) + if (ReturnValue & ACPI_REENABLE_GPE) { - Status = AcpiHwClearGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to clear GPE[%2X]", GpeNumber)); - return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); - } + (void) AcpiEvFinishGpe (GpeEventInfo); } break; case ACPI_GPE_DISPATCH_METHOD: - - /* - * Disable the GPE, so it doesn't keep firing before the method has a - * chance to run (it runs asynchronously with interrupts enabled). - */ - Status = AcpiEvDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to disable GPE[%2X]", GpeNumber)); - return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); - } + case ACPI_GPE_DISPATCH_NOTIFY: /* * Execute the method associated with the GPE @@ -865,30 +877,21 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to queue handler for GPE[%2X] - event disabled", + "Unable to queue handler for GPE%02X - event disabled", GpeNumber)); } break; default: - /* No handler or method to run! */ - - ACPI_ERROR ((AE_INFO, - "No handler or method for GPE[%2X], disabling event", - GpeNumber)); - /* - * Disable the GPE. The GPE will remain disabled until the ACPICA - * Core Subsystem is restarted, or a handler is installed. + * No handler or method to run! + * 03/2010: This case should no longer be possible. We will not allow + * a GPE to be enabled if it has no handler or method. */ - Status = AcpiEvDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to disable GPE[%2X]", GpeNumber)); - return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); - } + ACPI_ERROR ((AE_INFO, + "No handler or method for GPE%02X, disabling event", + GpeNumber)); break; } diff --git a/sys/contrib/dev/acpica-unix/events/evgpeblk.c b/sys/contrib/dev/acpica-unix/events/evgpeblk.c index 418d0d5064..c3ea571ca4 100644 --- a/sys/contrib/dev/acpica-unix/events/evgpeblk.c +++ b/sys/contrib/dev/acpica-unix/events/evgpeblk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -123,28 +123,6 @@ /* Local prototypes */ -static ACPI_STATUS -AcpiEvSaveMethodInfo ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *ObjDesc, - void **ReturnValue); - -static ACPI_STATUS -AcpiEvMatchPrwAndGpe ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Info, - void **ReturnValue); - -static ACPI_GPE_XRUPT_INFO * -AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber); - -static ACPI_STATUS -AcpiEvDeleteGpeXrupt ( - ACPI_GPE_XRUPT_INFO *GpeXrupt); - static ACPI_STATUS AcpiEvInstallGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock, @@ -155,597 +133,6 @@ AcpiEvCreateGpeInfoBlocks ( ACPI_GPE_BLOCK_INFO *GpeBlock); -/******************************************************************************* - * - * FUNCTION: AcpiEvValidGpeEvent - * - * PARAMETERS: GpeEventInfo - Info for this GPE - * - * RETURN: TRUE if the GpeEvent is valid - * - * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. - * Should be called only when the GPE lists are semaphore locked - * and not subject to change. - * - ******************************************************************************/ - -BOOLEAN -AcpiEvValidGpeEvent ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_XRUPT_INFO *GpeXruptBlock; - ACPI_GPE_BLOCK_INFO *GpeBlock; - - - ACPI_FUNCTION_ENTRY (); - - - /* No need for spin lock since we are not changing any list elements */ - - /* Walk the GPE interrupt levels */ - - GpeXruptBlock = AcpiGbl_GpeXruptListHead; - while (GpeXruptBlock) - { - GpeBlock = GpeXruptBlock->GpeBlockListHead; - - /* Walk the GPE blocks on this interrupt level */ - - while (GpeBlock) - { - if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && - (&GpeBlock->EventInfo[((ACPI_SIZE) - GpeBlock->RegisterCount) * 8] > GpeEventInfo)) - { - return (TRUE); - } - - GpeBlock = GpeBlock->Next; - } - - GpeXruptBlock = GpeXruptBlock->Next; - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvWalkGpeList - * - * PARAMETERS: GpeWalkCallback - Routine called for each GPE block - * Context - Value passed to callback - * - * RETURN: Status - * - * DESCRIPTION: Walk the GPE lists. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - void *Context) -{ - ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_GPE_XRUPT_INFO *GpeXruptInfo; - ACPI_STATUS Status = AE_OK; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvWalkGpeList); - - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - - /* Walk the interrupt level descriptor list */ - - GpeXruptInfo = AcpiGbl_GpeXruptListHead; - while (GpeXruptInfo) - { - /* Walk all Gpe Blocks attached to this interrupt level */ - - GpeBlock = GpeXruptInfo->GpeBlockListHead; - while (GpeBlock) - { - /* One callback per GPE block */ - - Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_CTRL_END) /* Callback abort */ - { - Status = AE_OK; - } - goto UnlockAndExit; - } - - GpeBlock = GpeBlock->Next; - } - - GpeXruptInfo = GpeXruptInfo->Next; - } - -UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvDeleteGpeHandlers - * - * PARAMETERS: GpeXruptInfo - GPE Interrupt info - * GpeBlock - Gpe Block info - * - * RETURN: Status - * - * DESCRIPTION: Delete all Handler objects found in the GPE data structs. - * Used only prior to termination. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvDeleteGpeHandlers ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context) -{ - ACPI_GPE_EVENT_INFO *GpeEventInfo; - UINT32 i; - UINT32 j; - - - ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers); - - - /* Examine each GPE Register within the block */ - - for (i = 0; i < GpeBlock->RegisterCount; i++) - { - /* Now look at the individual GPEs in this byte register */ - - for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) - { - GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * - ACPI_GPE_REGISTER_WIDTH) + j]; - - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_HANDLER) - { - ACPI_FREE (GpeEventInfo->Dispatch.Handler); - GpeEventInfo->Dispatch.Handler = NULL; - GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; - } - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvSaveMethodInfo - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a - * control method under the _GPE portion of the namespace. - * Extract the name and GPE type from the object, saving this - * information for quick lookup during GPE dispatch - * - * The name of each GPE control method is of the form: - * "_Lxx" or "_Exx" - * Where: - * L - means that the GPE is level triggered - * E - means that the GPE is edge triggered - * xx - is the GPE number [in HEX] - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvSaveMethodInfo ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *ObjDesc, - void **ReturnValue) -{ - ACPI_GPE_BLOCK_INFO *GpeBlock = (void *) ObjDesc; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - UINT32 GpeNumber; - char Name[ACPI_NAME_SIZE + 1]; - UINT8 Type; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvSaveMethodInfo); - - - /* - * _Lxx and _Exx GPE method support - * - * 1) Extract the name from the object and convert to a string - */ - ACPI_MOVE_32_TO_32 ( - Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer); - Name[ACPI_NAME_SIZE] = 0; - - /* - * 2) Edge/Level determination is based on the 2nd character - * of the method name - * - * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE - * if a _PRW object is found that points to this GPE. - */ - switch (Name[1]) - { - case 'L': - Type = ACPI_GPE_LEVEL_TRIGGERED; - break; - - case 'E': - Type = ACPI_GPE_EDGE_TRIGGERED; - break; - - default: - /* Unknown method type, just ignore it! */ - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Ignoring unknown GPE method type: %s " - "(name not of form _Lxx or _Exx)", - Name)); - return_ACPI_STATUS (AE_OK); - } - - /* Convert the last two characters of the name to the GPE Number */ - - GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); - if (GpeNumber == ACPI_UINT32_MAX) - { - /* Conversion failed; invalid method, just ignore it */ - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Could not extract GPE number from name: %s " - "(name is not of form _Lxx or _Exx)", - Name)); - return_ACPI_STATUS (AE_OK); - } - - /* Ensure that we have a valid GPE number for this GPE block */ - - if ((GpeNumber < GpeBlock->BlockBaseNumber) || - (GpeNumber >= (GpeBlock->BlockBaseNumber + - (GpeBlock->RegisterCount * 8)))) - { - /* - * Not valid for this GPE block, just ignore it. However, it may be - * valid for a different GPE block, since GPE0 and GPE1 methods both - * appear under \_GPE. - */ - return_ACPI_STATUS (AE_OK); - } - - /* - * Now we can add this information to the GpeEventInfo block for use - * during dispatch of this GPE. Default type is RUNTIME, although this may - * change when the _PRW methods are executed later. - */ - GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; - - GpeEventInfo->Flags = (UINT8) - (Type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); - - GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; - - /* Update enable mask, but don't enable the HW GPE as of yet */ - - Status = AcpiEvEnableGpe (GpeEventInfo, FALSE); - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Registered GPE method %s as GPE number 0x%.2X\n", - Name, GpeNumber)); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvMatchPrwAndGpe - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is - * not aborted on a single _PRW failure. - * - * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a - * Device. Run the _PRW method. If present, extract the GPE - * number and mark the GPE as a WAKE GPE. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvMatchPrwAndGpe ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Info, - void **ReturnValue) -{ - ACPI_GPE_WALK_INFO *GpeInfo = (void *) Info; - ACPI_NAMESPACE_NODE *GpeDevice; - ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_NAMESPACE_NODE *TargetGpeDevice; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_OPERAND_OBJECT *PkgDesc; - ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 GpeNumber; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvMatchPrwAndGpe); - - - /* Check for a _PRW method under this device */ - - Status = AcpiUtEvaluateObject (ObjHandle, METHOD_NAME__PRW, - ACPI_BTYPE_PACKAGE, &PkgDesc); - if (ACPI_FAILURE (Status)) - { - /* Ignore all errors from _PRW, we don't want to abort the subsystem */ - - return_ACPI_STATUS (AE_OK); - } - - /* The returned _PRW package must have at least two elements */ - - if (PkgDesc->Package.Count < 2) - { - goto Cleanup; - } - - /* Extract pointers from the input context */ - - GpeDevice = GpeInfo->GpeDevice; - GpeBlock = GpeInfo->GpeBlock; - - /* - * The _PRW object must return a package, we are only interested in the - * first element - */ - ObjDesc = PkgDesc->Package.Elements[0]; - - if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) - { - /* Use FADT-defined GPE device (from definition of _PRW) */ - - TargetGpeDevice = AcpiGbl_FadtGpeDevice; - - /* Integer is the GPE number in the FADT described GPE blocks */ - - GpeNumber = (UINT32) ObjDesc->Integer.Value; - } - else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Package contains a GPE reference and GPE number within a GPE block */ - - if ((ObjDesc->Package.Count < 2) || - ((ObjDesc->Package.Elements[0])->Common.Type != - ACPI_TYPE_LOCAL_REFERENCE) || - ((ObjDesc->Package.Elements[1])->Common.Type != - ACPI_TYPE_INTEGER)) - { - goto Cleanup; - } - - /* Get GPE block reference and decode */ - - TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node; - GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value; - } - else - { - /* Unknown type, just ignore it */ - - goto Cleanup; - } - - /* - * Is this GPE within this block? - * - * TRUE if and only if these conditions are true: - * 1) The GPE devices match. - * 2) The GPE index(number) is within the range of the Gpe Block - * associated with the GPE device. - */ - if ((GpeDevice == TargetGpeDevice) && - (GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + - (GpeBlock->RegisterCount * 8))) - { - GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - - GpeBlock->BlockBaseNumber]; - - /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ - - GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); - - Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); - } - -Cleanup: - AcpiUtRemoveReference (PkgDesc); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGetGpeXruptBlock - * - * PARAMETERS: InterruptNumber - Interrupt for a GPE block - * - * RETURN: A GPE interrupt block - * - * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt - * block per unique interrupt level used for GPEs. Should be - * called only when the GPE lists are semaphore locked and not - * subject to change. - * - ******************************************************************************/ - -static ACPI_GPE_XRUPT_INFO * -AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber) -{ - ACPI_GPE_XRUPT_INFO *NextGpeXrupt; - ACPI_GPE_XRUPT_INFO *GpeXrupt; - ACPI_STATUS Status; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); - - - /* No need for lock since we are not changing any list elements here */ - - NextGpeXrupt = AcpiGbl_GpeXruptListHead; - while (NextGpeXrupt) - { - if (NextGpeXrupt->InterruptNumber == InterruptNumber) - { - return_PTR (NextGpeXrupt); - } - - NextGpeXrupt = NextGpeXrupt->Next; - } - - /* Not found, must allocate a new xrupt descriptor */ - - GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); - if (!GpeXrupt) - { - return_PTR (NULL); - } - - GpeXrupt->InterruptNumber = InterruptNumber; - - /* Install new interrupt descriptor with spin lock */ - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (AcpiGbl_GpeXruptListHead) - { - NextGpeXrupt = AcpiGbl_GpeXruptListHead; - while (NextGpeXrupt->Next) - { - NextGpeXrupt = NextGpeXrupt->Next; - } - - NextGpeXrupt->Next = GpeXrupt; - GpeXrupt->Previous = NextGpeXrupt; - } - else - { - AcpiGbl_GpeXruptListHead = GpeXrupt; - } - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); - - /* Install new interrupt handler if not SCI_INT */ - - if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) - { - Status = AcpiOsInstallInterruptHandler (InterruptNumber, - AcpiEvGpeXruptHandler, GpeXrupt); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not install GPE interrupt handler at level 0x%X", - InterruptNumber)); - return_PTR (NULL); - } - } - - return_PTR (GpeXrupt); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvDeleteGpeXrupt - * - * PARAMETERS: GpeXrupt - A GPE interrupt info block - * - * RETURN: Status - * - * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated - * interrupt handler if not the SCI interrupt. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvDeleteGpeXrupt ( - ACPI_GPE_XRUPT_INFO *GpeXrupt) -{ - ACPI_STATUS Status; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); - - - /* We never want to remove the SCI interrupt handler */ - - if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) - { - GpeXrupt->GpeBlockListHead = NULL; - return_ACPI_STATUS (AE_OK); - } - - /* Disable this interrupt */ - - Status = AcpiOsRemoveInterruptHandler ( - GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Unlink the interrupt block with lock */ - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (GpeXrupt->Previous) - { - GpeXrupt->Previous->Next = GpeXrupt->Next; - } - else - { - /* No previous, update list head */ - - AcpiGbl_GpeXruptListHead = GpeXrupt->Next; - } - - if (GpeXrupt->Next) - { - GpeXrupt->Next->Previous = GpeXrupt->Previous; - } - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); - - /* Free the block */ - - ACPI_FREE (GpeXrupt); - return_ACPI_STATUS (AE_OK); -} - - /******************************************************************************* * * FUNCTION: AcpiEvInstallGpeBlock @@ -880,7 +267,7 @@ AcpiEvDeleteGpeBlock ( AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); } - AcpiCurrentGpeCount -= GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH; + AcpiCurrentGpeCount -= GpeBlock->GpeCount; /* Free the GpeBlock */ @@ -925,8 +312,8 @@ AcpiEvCreateGpeInfoBlocks ( /* Allocate the GPE register information block */ GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( - (ACPI_SIZE) GpeBlock->RegisterCount * - sizeof (ACPI_GPE_REGISTER_INFO)); + (ACPI_SIZE) GpeBlock->RegisterCount * + sizeof (ACPI_GPE_REGISTER_INFO)); if (!GpeRegisterInfo) { ACPI_ERROR ((AE_INFO, @@ -938,10 +325,8 @@ AcpiEvCreateGpeInfoBlocks ( * Allocate the GPE EventInfo block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ - GpeEventInfo = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) GpeBlock->RegisterCount * - ACPI_GPE_REGISTER_WIDTH) * - sizeof (ACPI_GPE_EVENT_INFO)); + GpeEventInfo = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) GpeBlock->GpeCount * + sizeof (ACPI_GPE_EVENT_INFO)); if (!GpeEventInfo) { ACPI_ERROR ((AE_INFO, @@ -995,7 +380,7 @@ AcpiEvCreateGpeInfoBlocks ( /* Disable all GPEs within this register */ - Status = AcpiWrite (0x00, &ThisRegister->EnableAddress); + Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1003,7 +388,7 @@ AcpiEvCreateGpeInfoBlocks ( /* Clear any pending GPE events within this register */ - Status = AcpiWrite (0xFF, &ThisRegister->StatusAddress); + Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1059,6 +444,7 @@ AcpiEvCreateGpeBlock ( { ACPI_STATUS Status; ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_WALK_INFO WalkInfo; ACPI_FUNCTION_TRACE (EvCreateGpeBlock); @@ -1080,6 +466,8 @@ AcpiEvCreateGpeBlock ( /* Initialize the new GPE block */ GpeBlock->Node = GpeDevice; + GpeBlock->GpeCount = (UINT16) (RegisterCount * ACPI_GPE_REGISTER_WIDTH); + GpeBlock->Initialized = FALSE; GpeBlock->RegisterCount = RegisterCount; GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; @@ -1106,11 +494,17 @@ AcpiEvCreateGpeBlock ( return_ACPI_STATUS (Status); } - /* Find all GPE methods (_Lxx, _Exx) for this block */ + AcpiGbl_AllGpesInitialized = FALSE; + + /* Find all GPE methods (_Lxx or_Exx) for this block */ + + WalkInfo.GpeBlock = GpeBlock; + WalkInfo.GpeDevice = GpeDevice; + WalkInfo.ExecuteByOwnerId = FALSE; Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiEvSaveMethodInfo, GpeBlock, NULL); + AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL); /* Return the new block */ @@ -1122,15 +516,13 @@ AcpiEvCreateGpeBlock ( ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", (UINT32) GpeBlock->BlockBaseNumber, - (UINT32) (GpeBlock->BlockBaseNumber + - ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), - GpeDevice->Name.Ascii, - GpeBlock->RegisterCount, + (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)), + GpeDevice->Name.Ascii, GpeBlock->RegisterCount, InterruptNumber)); /* Update global count of currently available GPEs */ - AcpiCurrentGpeCount += RegisterCount * ACPI_GPE_REGISTER_WIDTH; + AcpiCurrentGpeCount += GpeBlock->GpeCount; return_ACPI_STATUS (AE_OK); } @@ -1139,28 +531,26 @@ AcpiEvCreateGpeBlock ( * * FUNCTION: AcpiEvInitializeGpeBlock * - * PARAMETERS: GpeDevice - Handle to the parent GPE block - * GpeBlock - Gpe Block info + * PARAMETERS: ACPI_GPE_CALLBACK * * RETURN: Status * - * DESCRIPTION: Initialize and enable a GPE block. First find and run any - * _PRT methods associated with the block, then enable the - * appropriate GPEs. + * DESCRIPTION: Initialize and enable a GPE block. Enable GPEs that have + * associated methods. * Note: Assumes namespace is locked. * ******************************************************************************/ ACPI_STATUS AcpiEvInitializeGpeBlock ( - ACPI_NAMESPACE_NODE *GpeDevice, - ACPI_GPE_BLOCK_INFO *GpeBlock) + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Ignored) { ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_GPE_WALK_INFO GpeInfo; - UINT32 WakeGpeCount; UINT32 GpeEnabledCount; + UINT32 GpeIndex; UINT32 i; UINT32 j; @@ -1168,235 +558,62 @@ AcpiEvInitializeGpeBlock ( ACPI_FUNCTION_TRACE (EvInitializeGpeBlock); - /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ - - if (!GpeBlock) - { - return_ACPI_STATUS (AE_OK); - } - /* - * Runtime option: Should wake GPEs be enabled at runtime? The default - * is no, they should only be enabled just as the machine goes to sleep. + * Ignore a null GPE block (e.g., if no GPE block 1 exists), and + * any GPE blocks that have been initialized already. */ - if (AcpiGbl_LeaveWakeGpesDisabled) + if (!GpeBlock || GpeBlock->Initialized) { - /* - * Differentiate runtime vs wake GPEs, via the _PRW control methods. - * Each GPE that has one or more _PRWs that reference it is by - * definition a wake GPE and will not be enabled while the machine - * is running. - */ - GpeInfo.GpeBlock = GpeBlock; - GpeInfo.GpeDevice = GpeDevice; - - Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiEvMatchPrwAndGpe, &GpeInfo, NULL); + return_ACPI_STATUS (AE_OK); } /* - * Enable all GPEs in this block that have these attributes: - * 1) are "runtime" or "run/wake" GPEs, and - * 2) have a corresponding _Lxx or _Exx method - * - * Any other GPEs within this block must be enabled via the - * AcpiEnableGpe() external interface. + * Enable all GPEs that have a corresponding method and have the + * ACPI_GPE_CAN_WAKE flag unset. Any other GPEs within this block + * must be enabled via the acpi_enable_gpe() interface. */ - WakeGpeCount = 0; GpeEnabledCount = 0; for (i = 0; i < GpeBlock->RegisterCount; i++) { - for (j = 0; j < 8; j++) + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { /* Get the info block for this particular GPE */ - GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * - ACPI_GPE_REGISTER_WIDTH) + j]; - - if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_METHOD) && - (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) - { - GpeEnabledCount++; - } + GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; + GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; - if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + /* + * Ignore GPEs that have no corresponding _Lxx/_Exx method + * and GPEs that are used to wake the system + */ + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_NONE) || + ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) || + (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) { - WakeGpeCount++; + continue; } - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Found %u Wake, Enabled %u Runtime GPEs in this block\n", - WakeGpeCount, GpeEnabledCount)); - - /* Enable all valid runtime GPEs found above */ - - Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock, NULL); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not enable GPEs in GpeBlock %p", - GpeBlock)); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGpeInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the GPE data structures - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvGpeInitialize ( - void) -{ - UINT32 RegisterCount0 = 0; - UINT32 RegisterCount1 = 0; - UINT32 GpeNumberMax = 0; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvGpeInitialize); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Initialize the GPE Block(s) defined in the FADT - * - * Why the GPE register block lengths are divided by 2: From the ACPI - * Spec, section "General-Purpose Event Registers", we have: - * - * "Each register block contains two registers of equal length - * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the - * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN - * The length of the GPE1_STS and GPE1_EN registers is equal to - * half the GPE1_LEN. If a generic register block is not supported - * then its respective block pointer and block length values in the - * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need - * to be the same size." - */ - - /* - * Determine the maximum GPE number for this machine. - * - * Note: both GPE0 and GPE1 are optional, and either can exist without - * the other. - * - * If EITHER the register length OR the block address are zero, then that - * particular block is not supported. - */ - if (AcpiGbl_FADT.Gpe0BlockLength && - AcpiGbl_FADT.XGpe0Block.Address) - { - /* GPE block 0 exists (has both length and address > 0) */ - - RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); - - GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; - - /* Install GPE Block 0 */ - - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not create GPE Block 0")); - } - } - - if (AcpiGbl_FADT.Gpe1BlockLength && - AcpiGbl_FADT.XGpe1Block.Address) - { - /* GPE block 1 exists (has both length and address > 0) */ - - RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); - - /* Check for GPE0/GPE1 overlap (if both banks exist) */ - - if ((RegisterCount0) && - (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) - { - ACPI_ERROR ((AE_INFO, - "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " - "(GPE %d to %d) - Ignoring GPE1", - GpeNumberMax, AcpiGbl_FADT.Gpe1Base, - AcpiGbl_FADT.Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); - - /* Ignore GPE1 block by setting the register count to zero */ - - RegisterCount1 = 0; - } - else - { - /* Install GPE Block 1 */ - - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe1Block, RegisterCount1, - AcpiGbl_FADT.Gpe1Base, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + Status = AcpiEvAddGpeReference (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Could not create GPE Block 1")); + "Could not enable GPE 0x%02X", + GpeIndex + GpeBlock->BlockBaseNumber)); + continue; } - /* - * GPE0 and GPE1 do not have to be contiguous in the GPE number - * space. However, GPE0 always starts at GPE number zero. - */ - GpeNumberMax = AcpiGbl_FADT.Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + GpeEnabledCount++; } } - /* Exit if there are no GPE registers */ - - if ((RegisterCount0 + RegisterCount1) == 0) + if (GpeEnabledCount) { - /* GPEs are not required by ACPI, this is OK */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "There are no GPE blocks defined in the FADT\n")); - Status = AE_OK; - goto Cleanup; + "Enabled %u GPEs in this block\n", GpeEnabledCount)); } - /* Check for Max GPE number out-of-range */ - - if (GpeNumberMax > ACPI_GPE_MAX) - { - ACPI_ERROR ((AE_INFO, - "Maximum GPE number from FADT is too large: 0x%X", - GpeNumberMax)); - Status = AE_BAD_VALUE; - goto Cleanup; - } - -Cleanup: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + GpeBlock->Initialized = TRUE; return_ACPI_STATUS (AE_OK); } - diff --git a/sys/contrib/dev/acpica-unix/events/evgpeinit.c b/sys/contrib/dev/acpica-unix/events/evgpeinit.c new file mode 100644 index 0000000000..8bba11166c --- /dev/null +++ b/sys/contrib/dev/acpica-unix/events/evgpeinit.c @@ -0,0 +1,531 @@ +/****************************************************************************** + * + * Module Name: evgpeinit - System GPE initialization and update + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States 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 "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeinit") + + +/* + * Note: History of _PRW support in ACPICA + * + * Originally (2000 - 2010), the GPE initialization code performed a walk of + * the entire namespace to execute the _PRW methods and detect all GPEs + * capable of waking the system. + * + * As of 10/2010, the _PRW method execution has been removed since it is + * actually unnecessary. The host OS must in fact execute all _PRW methods + * in order to identify the device/power-resource dependencies. We now put + * the onus on the host OS to identify the wake GPEs as part of this process + * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This + * not only reduces the complexity of the ACPICA initialization code, but in + * some cases (on systems with very large namespaces) it should reduce the + * kernel boot time as well. + */ + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void) +{ + UINT32 RegisterCount0 = 0; + UINT32 RegisterCount1 = 0; + UINT32 GpeNumberMax = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize the GPE Block(s) defined in the FADT + * + * Why the GPE register block lengths are divided by 2: From the ACPI + * Spec, section "General-Purpose Event Registers", we have: + * + * "Each register block contains two registers of equal length + * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the + * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN + * The length of the GPE1_STS and GPE1_EN registers is equal to + * half the GPE1_LEN. If a generic register block is not supported + * then its respective block pointer and block length values in the + * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need + * to be the same size." + */ + + /* + * Determine the maximum GPE number for this machine. + * + * Note: both GPE0 and GPE1 are optional, and either can exist without + * the other. + * + * If EITHER the register length OR the block address are zero, then that + * particular block is not supported. + */ + if (AcpiGbl_FADT.Gpe0BlockLength && + AcpiGbl_FADT.XGpe0Block.Address) + { + /* GPE block 0 exists (has both length and address > 0) */ + + RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); + + GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; + + /* Install GPE Block 0 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 0")); + } + } + + if (AcpiGbl_FADT.Gpe1BlockLength && + AcpiGbl_FADT.XGpe1Block.Address) + { + /* GPE block 1 exists (has both length and address > 0) */ + + RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); + + /* Check for GPE0/GPE1 overlap (if both banks exist) */ + + if ((RegisterCount0) && + (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) + { + ACPI_ERROR ((AE_INFO, + "GPE0 block (GPE 0 to %u) overlaps the GPE1 block " + "(GPE %u to %u) - Ignoring GPE1", + GpeNumberMax, AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + + /* Ignore GPE1 block by setting the register count to zero */ + + RegisterCount1 = 0; + } + else + { + /* Install GPE Block 1 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 1")); + } + + /* + * GPE0 and GPE1 do not have to be contiguous in the GPE number + * space. However, GPE0 always starts at GPE number zero. + */ + GpeNumberMax = AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + } + } + + /* Exit if there are no GPE registers */ + + if ((RegisterCount0 + RegisterCount1) == 0) + { + /* GPEs are not required by ACPI, this is OK */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); + Status = AE_OK; + goto Cleanup; + } + + /* Check for Max GPE number out-of-range */ + + if (GpeNumberMax > ACPI_GPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Maximum GPE number from FADT is too large: 0x%X", + GpeNumberMax)); + Status = AE_BAD_VALUE; + goto Cleanup; + } + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpes + * + * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table + * + * RETURN: None + * + * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a + * result of a Load() or LoadTable() operation. If new GPE + * methods have been installed, register the new methods. + * + ******************************************************************************/ + +void +AcpiEvUpdateGpes ( + ACPI_OWNER_ID TableOwnerId) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_WALK_INFO WalkInfo; + ACPI_STATUS Status = AE_OK; + + + /* + * Find any _Lxx/_Exx GPE methods that have just been loaded. + * + * Any GPEs that correspond to new _Lxx/_Exx methods are immediately + * enabled. + * + * Examine the namespace underneath each GpeDevice within the + * GpeBlock lists. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return; + } + + WalkInfo.Count = 0; + WalkInfo.OwnerId = TableOwnerId; + WalkInfo.ExecuteByOwnerId = TRUE; + + /* Walk the interrupt level descriptor list */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + WalkInfo.GpeBlock = GpeBlock; + WalkInfo.GpeDevice = GpeBlock->Node; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, + WalkInfo.GpeDevice, ACPI_UINT32_MAX, + ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod, + NULL, &WalkInfo, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While decoding _Lxx/_Exx methods")); + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptInfo = GpeXruptInfo->Next; + } + + if (WalkInfo.Count) + { + ACPI_INFO ((AE_INFO, "Enabled %u new GPEs", WalkInfo.Count)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvMatchGpeMethod + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch. Allows a + * per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the + * WalkInfo parameter block. + * + * The name of each GPE control method is of the form: + * "_Lxx" or "_Exx", where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * xx - is the GPE number [in HEX] + * + * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods + * with that owner. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvMatchGpeMethod ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 GpeNumber; + char Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + + + ACPI_FUNCTION_TRACE (EvMatchGpeMethod); + + + /* Check if requested OwnerId matches this OwnerId */ + + if ((WalkInfo->ExecuteByOwnerId) && + (MethodNode->OwnerId != WalkInfo->OwnerId)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Match and decode the _Lxx and _Exx GPE method names + * + * 1) Extract the method name and null terminate it + */ + ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer); + Name[ACPI_NAME_SIZE] = 0; + + /* 2) Name must begin with an underscore */ + + if (Name[0] != '_') + { + return_ACPI_STATUS (AE_OK); /* Ignore this method */ + } + + /* + * 3) Edge/Level determination is based on the 2nd character + * of the method name + */ + switch (Name[1]) + { + case 'L': + Type = ACPI_GPE_LEVEL_TRIGGERED; + break; + + case 'E': + Type = ACPI_GPE_EDGE_TRIGGERED; + break; + + default: + /* Unknown method type, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", Name)); + return_ACPI_STATUS (AE_OK); + } + + /* 4) The last two characters of the name are the hex GPE Number */ + + GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Ensure that we have a valid GPE number for this GPE block */ + + GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); + if (!GpeEventInfo) + { + /* + * This GpeNumber is not valid for this GPE block, just ignore it. + * However, it may be valid for a different GPE block, since GPE0 + * and GPE1 methods both appear under \_GPE. + */ + return_ACPI_STATUS (AE_OK); + } + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + /* If there is already a handler, ignore this GPE method */ + + return_ACPI_STATUS (AE_OK); + } + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) + { + /* + * If there is already a method, ignore this method. But check + * for a type mismatch (if both the _Lxx AND _Exx exist) + */ + if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK)) + { + ACPI_ERROR ((AE_INFO, + "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", + GpeNumber, GpeNumber, GpeNumber)); + } + return_ACPI_STATUS (AE_OK); + } + + /* + * Add the GPE information from above to the GpeEventInfo block for + * use during dispatch of this GPE. + */ + GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK); + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD); + GpeEventInfo->Dispatch.MethodNode = MethodNode; + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Registered GPE method %s as GPE number 0x%.2X\n", + Name, GpeNumber)); + return_ACPI_STATUS (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/utilities/utmutex.c b/sys/contrib/dev/acpica-unix/events/evgpeutil.c similarity index 50% copy from sys/contrib/dev/acpica-unix/utilities/utmutex.c copy to sys/contrib/dev/acpica-unix/events/evgpeutil.c index f6e7cc3652..21c793adb1 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utmutex.c +++ b/sys/contrib/dev/acpica-unix/events/evgpeutil.c @@ -1,14 +1,14 @@ -/******************************************************************************* +/****************************************************************************** * - * Module Name: utmutex - local mutex support + * Module Name: evgpeutil - GPE utilities * - ******************************************************************************/ + *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,364 +114,382 @@ *****************************************************************************/ -#define __UTMUTEX_C__ - #include "acpi.h" #include "accommon.h" +#include "acevents.h" -#define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmutex") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiUtCreateMutex ( - ACPI_MUTEX_HANDLE MutexId); - -static ACPI_STATUS -AcpiUtDeleteMutex ( - ACPI_MUTEX_HANDLE MutexId); +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeutil") /******************************************************************************* * - * FUNCTION: AcpiUtMutexInitialize + * FUNCTION: AcpiEvWalkGpeList * - * PARAMETERS: None. + * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Context - Value passed to callback * * RETURN: Status * - * DESCRIPTION: Create the system mutex objects. This includes mutexes, - * spin locks, and reader/writer locks. + * DESCRIPTION: Walk the GPE lists. * ******************************************************************************/ ACPI_STATUS -AcpiUtMutexInitialize ( - void) +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context) { - UINT32 i; - ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_STATUS Status = AE_OK; + ACPI_CPU_FLAGS Flags; + + ACPI_FUNCTION_TRACE (EvWalkGpeList); - ACPI_FUNCTION_TRACE (UtMutexInitialize); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - /* Create each of the predefined mutex objects */ + /* Walk the interrupt level descriptor list */ - for (i = 0; i < ACPI_NUM_MUTEX; i++) + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) { - Status = AcpiUtCreateMutex (i); - if (ACPI_FAILURE (Status)) + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) { - return_ACPI_STATUS (Status); - } - } + /* One callback per GPE block */ - /* Create the spinlocks for use at interrupt level */ + Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_END) /* Callback abort */ + { + Status = AE_OK; + } + goto UnlockAndExit; + } - Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + GpeBlock = GpeBlock->Next; + } - Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); + GpeXruptInfo = GpeXruptInfo->Next; } - /* Create the reader/writer lock for namespace access */ - - Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiUtMutexTerminate + * FUNCTION: AcpiEvValidGpeEvent * - * PARAMETERS: None. + * PARAMETERS: GpeEventInfo - Info for this GPE * - * RETURN: None. + * RETURN: TRUE if the GpeEvent is valid * - * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, - * spin locks, and reader/writer locks. + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. * ******************************************************************************/ -void -AcpiUtMutexTerminate ( - void) +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) { - UINT32 i; + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_FUNCTION_TRACE (UtMutexTerminate); + ACPI_FUNCTION_ENTRY (); - /* Delete each predefined mutex object */ + /* No need for spin lock since we are not changing any list elements */ - for (i = 0; i < ACPI_NUM_MUTEX; i++) + /* Walk the GPE interrupt levels */ + + GpeXruptBlock = AcpiGbl_GpeXruptListHead; + while (GpeXruptBlock) { - (void) AcpiUtDeleteMutex (i); - } + GpeBlock = GpeXruptBlock->GpeBlockListHead; - /* Delete the spinlocks */ + /* Walk the GPE blocks on this interrupt level */ + + while (GpeBlock) + { + if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && + (&GpeBlock->EventInfo[GpeBlock->GpeCount] > GpeEventInfo)) + { + return (TRUE); + } - AcpiOsDeleteLock (AcpiGbl_GpeLock); - AcpiOsDeleteLock (AcpiGbl_HardwareLock); + GpeBlock = GpeBlock->Next; + } - /* Delete the reader/writer lock */ + GpeXruptBlock = GpeXruptBlock->Next; + } - AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); - return_VOID; + return (FALSE); } /******************************************************************************* * - * FUNCTION: AcpiUtCreateMutex + * FUNCTION: AcpiEvGetGpeDevice * - * PARAMETERS: MutexID - ID of the mutex to be created + * PARAMETERS: GPE_WALK_CALLBACK * * RETURN: Status * - * DESCRIPTION: Create a mutex object. + * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE + * block device. NULL if the GPE is one of the FADT-defined GPEs. * ******************************************************************************/ -static ACPI_STATUS -AcpiUtCreateMutex ( - ACPI_MUTEX_HANDLE MutexId) +ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { - ACPI_STATUS Status = AE_OK; + ACPI_GPE_DEVICE_INFO *Info = Context; - ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); + /* Increment Index by the number of GPEs in this block */ + Info->NextBlockBaseIndex += GpeBlock->GpeCount; - if (MutexId > ACPI_MAX_MUTEX) + if (Info->Index < Info->NextBlockBaseIndex) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + /* + * The GPE index is within this block, get the node. Leave the node + * NULL for the FADT-defined GPEs + */ + if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) + { + Info->GpeDevice = GpeBlock->Node; + } - if (!AcpiGbl_MutexInfo[MutexId].Mutex) - { - Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); - AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - AcpiGbl_MutexInfo[MutexId].UseCount = 0; + Info->Status = AE_OK; + return (AE_CTRL_END); } - return_ACPI_STATUS (Status); + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiUtDeleteMutex + * FUNCTION: AcpiEvGetGpeXruptBlock * - * PARAMETERS: MutexID - ID of the mutex to be deleted + * PARAMETERS: InterruptNumber - Interrupt for a GPE block * - * RETURN: Status + * RETURN: A GPE interrupt block * - * DESCRIPTION: Delete a mutex object. + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt + * block per unique interrupt level used for GPEs. Should be + * called only when the GPE lists are semaphore locked and not + * subject to change. * ******************************************************************************/ -static ACPI_STATUS -AcpiUtDeleteMutex ( - ACPI_MUTEX_HANDLE MutexId) +ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber) { + ACPI_GPE_XRUPT_INFO *NextGpeXrupt; + ACPI_GPE_XRUPT_INFO *GpeXrupt; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); - ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId); + /* No need for lock since we are not changing any list elements here */ - if (MutexId > ACPI_MAX_MUTEX) + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + if (NextGpeXrupt->InterruptNumber == InterruptNumber) + { + return_PTR (NextGpeXrupt); + } + + NextGpeXrupt = NextGpeXrupt->Next; } - AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + /* Not found, must allocate a new xrupt descriptor */ - AcpiGbl_MutexInfo[MutexId].Mutex = NULL; - AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); + if (!GpeXrupt) + { + return_PTR (NULL); + } - return_ACPI_STATUS (AE_OK); + GpeXrupt->InterruptNumber = InterruptNumber; + + /* Install new interrupt descriptor with spin lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (AcpiGbl_GpeXruptListHead) + { + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt->Next) + { + NextGpeXrupt = NextGpeXrupt->Next; + } + + NextGpeXrupt->Next = GpeXrupt; + GpeXrupt->Previous = NextGpeXrupt; + } + else + { + AcpiGbl_GpeXruptListHead = GpeXrupt; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Install new interrupt handler if not SCI_INT */ + + if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) + { + Status = AcpiOsInstallInterruptHandler (InterruptNumber, + AcpiEvGpeXruptHandler, GpeXrupt); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not install GPE interrupt handler at level 0x%X", + InterruptNumber)); + return_PTR (NULL); + } + } + + return_PTR (GpeXrupt); } /******************************************************************************* * - * FUNCTION: AcpiUtAcquireMutex + * FUNCTION: AcpiEvDeleteGpeXrupt * - * PARAMETERS: MutexID - ID of the mutex to be acquired + * PARAMETERS: GpeXrupt - A GPE interrupt info block * * RETURN: Status * - * DESCRIPTION: Acquire a mutex object. + * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated + * interrupt handler if not the SCI interrupt. * ******************************************************************************/ ACPI_STATUS -AcpiUtAcquireMutex ( - ACPI_MUTEX_HANDLE MutexId) +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt) { ACPI_STATUS Status; - ACPI_THREAD_ID ThisThreadId; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_NAME (UtAcquireMutex); + ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); - if (MutexId > ACPI_MAX_MUTEX) + /* We never want to remove the SCI interrupt handler */ + + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) { - return (AE_BAD_PARAMETER); + GpeXrupt->GpeBlockListHead = NULL; + return_ACPI_STATUS (AE_OK); } - ThisThreadId = AcpiOsGetThreadId (); + /* Disable this interrupt */ -#ifdef ACPI_MUTEX_DEBUG + Status = AcpiOsRemoveInterruptHandler ( + GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); + if (ACPI_FAILURE (Status)) { - UINT32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = MutexId; i < ACPI_NUM_MUTEX; i++) - { - if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) - { - if (i == MutexId) - { - ACPI_ERROR ((AE_INFO, - "Mutex [%s] already acquired by this thread [%p]", - AcpiUtGetMutexName (MutexId), - ACPI_CAST_PTR (void, ThisThreadId))); - - return (AE_ALREADY_ACQUIRED); - } - - ACPI_ERROR ((AE_INFO, - "Invalid acquire order: Thread %p owns [%s], wants [%s]", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i), - AcpiUtGetMutexName (MutexId))); - - return (AE_ACQUIRE_DEADLOCK); - } - } + return_ACPI_STATUS (Status); } -#endif - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %p attempting to acquire Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + /* Unlink the interrupt block with lock */ - Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, - ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (Status)) + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXrupt->Previous) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); - - AcpiGbl_MutexInfo[MutexId].UseCount++; - AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; + GpeXrupt->Previous->Next = GpeXrupt->Next; } else { - ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %p could not acquire Mutex [%X]", - ACPI_CAST_PTR (void, ThisThreadId), MutexId)); + /* No previous, update list head */ + + AcpiGbl_GpeXruptListHead = GpeXrupt->Next; + } + + if (GpeXrupt->Next) + { + GpeXrupt->Next->Previous = GpeXrupt->Previous; } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Free the block */ - return (Status); + ACPI_FREE (GpeXrupt); + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiUtReleaseMutex + * FUNCTION: AcpiEvDeleteGpeHandlers * - * PARAMETERS: MutexID - ID of the mutex to be released + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info * * RETURN: Status * - * DESCRIPTION: Release a mutex object. + * DESCRIPTION: Delete all Handler objects found in the GPE data structs. + * Used only prior to termination. * ******************************************************************************/ ACPI_STATUS -AcpiUtReleaseMutex ( - ACPI_MUTEX_HANDLE MutexId) +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) { - ACPI_THREAD_ID ThisThreadId; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 i; + UINT32 j; - ACPI_FUNCTION_NAME (UtReleaseMutex); + ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers); - ThisThreadId = AcpiOsGetThreadId (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + /* Examine each GPE Register within the block */ - if (MutexId > ACPI_MAX_MUTEX) + for (i = 0; i < GpeBlock->RegisterCount; i++) { - return (AE_BAD_PARAMETER); - } - - /* - * Mutex must be acquired in order to release it! - */ - if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) - { - ACPI_ERROR ((AE_INFO, - "Mutex [%X] is not acquired, cannot release", MutexId)); - - return (AE_NOT_ACQUIRED); - } + /* Now look at the individual GPEs in this byte register */ -#ifdef ACPI_MUTEX_DEBUG - { - UINT32 i; - /* - * Mutex debug code, for internal debugging only. - * - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated the mutex - * ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) - { - if (i == MutexId) - { - continue; - } - - ACPI_ERROR ((AE_INFO, - "Invalid release order: owns [%s], releasing [%s]", - AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; - return (AE_RELEASE_DEADLOCK); + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; } } } -#endif - - /* Mark unlocked FIRST */ - AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - - AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex); - return (AE_OK); + return_ACPI_STATUS (AE_OK); } - - diff --git a/sys/contrib/dev/acpica-unix/events/evmisc.c b/sys/contrib/dev/acpica-unix/events/evmisc.c index 1e7f9e1cb5..d7a14e25ad 100644 --- a/sys/contrib/dev/acpica-unix/events/evmisc.c +++ b/sys/contrib/dev/acpica-unix/events/evmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -696,7 +696,7 @@ AcpiEvTerminate ( if (ACPI_FAILURE (Status)) { ACPI_ERROR ((AE_INFO, - "Could not disable fixed event %d", (UINT32) i)); + "Could not disable fixed event %u", (UINT32) i)); } } diff --git a/sys/contrib/dev/acpica-unix/events/evregion.c b/sys/contrib/dev/acpica-unix/events/evregion.c index 32d7b642f9..7f26c2b5ef 100644 --- a/sys/contrib/dev/acpica-unix/events/evregion.c +++ b/sys/contrib/dev/acpica-unix/events/evregion.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -128,6 +128,11 @@ /* Local prototypes */ +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + static ACPI_STATUS AcpiEvRegRun ( ACPI_HANDLE ObjHandle, @@ -231,6 +236,57 @@ UnlockAndExit: } +/******************************************************************************* + * + * FUNCTION: AcpiEvHasDefaultHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: TRUE if default handler is installed, FALSE otherwise + * + * DESCRIPTION: Check if the default handler is installed for the requested + * space ID. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + + + /* Must have an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the linked list of handlers for this object */ + + while (HandlerObj) + { + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + return (TRUE); + } + } + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + return (FALSE); +} + + /******************************************************************************* * * FUNCTION: AcpiEvInitializeOpRegions @@ -266,13 +322,20 @@ AcpiEvInitializeOpRegions ( for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { /* - * TBD: Make sure handler is the DEFAULT handler, otherwise - * _REG will have already been run. + * Make sure the installed handler is the DEFAULT handler. If not the + * default, the _REG methods will have already been run (when the + * handler was installed) */ - Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, - AcpiGbl_DefaultAddressSpaces[i]); + if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i])) + { + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } } + AcpiGbl_RegMethodsExecuted = TRUE; + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } @@ -339,25 +402,21 @@ AcpiEvExecuteRegMethod ( * connection status 1 for connecting the handler, 0 for disconnecting * the handler (Passed as a parameter) */ - Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId); if (!Args[0]) { Status = AE_NO_MEMORY; goto Cleanup1; } - Args[1] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function); if (!Args[1]) { Status = AE_NO_MEMORY; goto Cleanup2; } - /* Setup the parameter objects */ - - Args[0]->Integer.Value = RegionObj->Region.SpaceId; - Args[1]->Integer.Value = Function; - Args[2] = NULL; + Args[2] = NULL; /* Terminate list */ /* Execute the method, no return value */ @@ -385,7 +444,7 @@ Cleanup1: * RegionOffset - Where in the region to read or write * BitWidth - Field width in bits (8, 16, 32, or 64) * Value - Pointer to in or out value, must be - * full 64-bit ACPI_INTEGER + * a full 64-bit integer * * RETURN: Status * @@ -400,7 +459,7 @@ AcpiEvAddressSpaceDispatch ( UINT32 Function, UINT32 RegionOffset, UINT32 BitWidth, - ACPI_INTEGER *Value) + UINT64 *Value) { ACPI_STATUS Status; ACPI_ADR_SPACE_HANDLER Handler; @@ -788,7 +847,7 @@ AcpiEvInstallHandler ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); if (!Node) { return (AE_BAD_PARAMETER); @@ -1112,7 +1171,7 @@ AcpiEvInstallSpaceHandler ( * of the branch */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL, HandlerObj, NULL); UnlockAndExit: @@ -1152,7 +1211,7 @@ AcpiEvExecuteRegMethods ( * regions of this Space ID before we can run any _REG methods) */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, &SpaceId, NULL); return_ACPI_STATUS (Status); @@ -1186,7 +1245,7 @@ AcpiEvRegRun ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); if (!Node) { return (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica-unix/events/evrgnini.c b/sys/contrib/dev/acpica-unix/events/evrgnini.c index 187aebe58f..64363c5924 100644 --- a/sys/contrib/dev/acpica-unix/events/evrgnini.c +++ b/sys/contrib/dev/acpica-unix/events/evrgnini.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -126,10 +126,6 @@ /* Local prototypes */ -static BOOLEAN -AcpiEvMatchPciRootBridge ( - char *Id); - static BOOLEAN AcpiEvIsPciRootBridge ( ACPI_NAMESPACE_NODE *Node); @@ -264,7 +260,7 @@ AcpiEvPciConfigRegionSetup ( void **RegionContext) { ACPI_STATUS Status = AE_OK; - ACPI_INTEGER PciValue; + UINT64 PciValue; ACPI_PCI_ID *PciId = *RegionContext; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_NAMESPACE_NODE *ParentNode; @@ -298,7 +294,7 @@ AcpiEvPciConfigRegionSetup ( return_ACPI_STATUS (Status); } - ParentNode = AcpiNsGetParentNode (RegionObj->Region.Node); + ParentNode = RegionObj->Region.Node->Parent; /* * Get the _SEG and _BBN values from the device upon which the handler @@ -352,7 +348,7 @@ AcpiEvPciConfigRegionSetup ( break; } - PciRootNode = AcpiNsGetParentNode (PciRootNode); + PciRootNode = PciRootNode->Parent; } /* PCI root bridge not found, use namespace root node */ @@ -389,7 +385,7 @@ AcpiEvPciConfigRegionSetup ( PciDeviceNode = RegionObj->Region.Node; while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) { - PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); + PciDeviceNode = PciDeviceNode->Parent; } if (!PciDeviceNode) @@ -399,8 +395,8 @@ AcpiEvPciConfigRegionSetup ( } /* - * Get the PCI device and function numbers from the _ADR object contained - * in the parent's scope. + * Get the PCI device and function numbers from the _ADR object + * contained in the parent's scope. */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, PciDeviceNode, &PciValue); @@ -433,48 +429,17 @@ AcpiEvPciConfigRegionSetup ( PciId->Bus = ACPI_LOWORD (PciValue); } - /* Complete this device's PciId */ - - AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); - - *RegionContext = PciId; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvMatchPciRootBridge - * - * PARAMETERS: Id - The HID/CID in string format - * - * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge - * - * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. - * - ******************************************************************************/ - -static BOOLEAN -AcpiEvMatchPciRootBridge ( - char *Id) -{ - - /* - * Check if this is a PCI root. - * ACPI 3.0+: check for a PCI Express root also. - */ - if (!(ACPI_STRNCMP (Id, - PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING))) || + /* Complete/update the PCI ID for this device */ - !(ACPI_STRNCMP (Id, - PCI_EXPRESS_ROOT_HID_STRING, - sizeof (PCI_EXPRESS_ROOT_HID_STRING)))) + Status = AcpiHwDerivePciId (PciId, PciRootNode, RegionObj->Region.Node); + if (ACPI_FAILURE (Status)) { - return (TRUE); + ACPI_FREE (PciId); + return_ACPI_STATUS (Status); } - return (FALSE); + *RegionContext = PciId; + return_ACPI_STATUS (AE_OK); } @@ -496,9 +461,10 @@ AcpiEvIsPciRootBridge ( ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; - ACPI_DEVICE_ID Hid; - ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; UINT32 i; + BOOLEAN Match; /* Get the _HID and check for a PCI Root Bridge */ @@ -509,7 +475,10 @@ AcpiEvIsPciRootBridge ( return (FALSE); } - if (AcpiEvMatchPciRootBridge (Hid.Value)) + Match = AcpiUtIsPciRootBridge (Hid->String); + ACPI_FREE (Hid); + + if (Match) { return (TRUE); } @@ -526,7 +495,7 @@ AcpiEvIsPciRootBridge ( for (i = 0; i < Cid->Count; i++) { - if (AcpiEvMatchPciRootBridge (Cid->Id[i].Value)) + if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) { ACPI_FREE (Cid); return (TRUE); @@ -697,7 +666,7 @@ AcpiEvInitializeRegion ( return_ACPI_STATUS (AE_NOT_EXIST); } - Node = AcpiNsGetParentNode (RegionObj->Region.Node); + Node = RegionObj->Region.Node->Parent; SpaceId = RegionObj->Region.SpaceId; /* Setup defaults */ @@ -752,6 +721,20 @@ AcpiEvInitializeRegion ( HandlerObj = ObjDesc->ThermalZone.Handler; break; + case ACPI_TYPE_METHOD: + /* + * If we are executing module level code, the original + * Node's object was replaced by this Method object and we + * saved the handler in the method object. + * + * See AcpiNsExecModuleCode + */ + if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) + { + HandlerObj = ObjDesc->Method.Dispatch.Handler; + } + break; + default: /* Ignore other objects */ break; @@ -807,7 +790,7 @@ AcpiEvInitializeRegion ( /* This node does not have the handler we need; Pop up one level */ - Node = AcpiNsGetParentNode (Node); + Node = Node->Parent; } /* If we get here, there is no handler for this region */ diff --git a/sys/contrib/dev/acpica-unix/events/evsci.c b/sys/contrib/dev/acpica-unix/events/evsci.c index cde433ce3e..e0d9261acf 100644 --- a/sys/contrib/dev/acpica-unix/events/evsci.c +++ b/sys/contrib/dev/acpica-unix/events/evsci.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/events/evxface.c b/sys/contrib/dev/acpica-unix/events/evxface.c index f816abad3a..990ddfb0b8 100644 --- a/sys/contrib/dev/acpica-unix/events/evxface.c +++ b/sys/contrib/dev/acpica-unix/events/evxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -175,6 +175,66 @@ Cleanup: ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler) +/******************************************************************************* + * + * FUNCTION: AcpiInstallGlobalEventHandler + * + * PARAMETERS: Handler - Pointer to the global event handler function + * Context - Value passed to the handler on each event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function. The global handler + * is invoked upon each incoming GPE and Fixed Event. It is + * invoked at interrupt level at the time of the event dispatch. + * Can be used to update event counters, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGlobalEventHandler ( + ACPI_GBL_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallGlobalEventHandler); + + + /* Parameter validation */ + + if (!Handler) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_GlobalEventHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + AcpiGbl_GlobalEventHandler = Handler; + AcpiGbl_GlobalEventHandlerContext = Context; + + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGlobalEventHandler) + + /******************************************************************************* * * FUNCTION: AcpiInstallFixedEventHandler @@ -232,7 +292,7 @@ AcpiInstallFixedEventHandler ( Status = AcpiEnableEvent (Event, 0); if (ACPI_FAILURE (Status)) { - ACPI_WARNING ((AE_INFO, "Could not enable fixed event %X", Event)); + ACPI_WARNING ((AE_INFO, "Could not enable fixed event 0x%X", Event)); /* Remove the handler */ @@ -303,7 +363,7 @@ AcpiRemoveFixedEventHandler ( if (ACPI_FAILURE (Status)) { ACPI_WARNING ((AE_INFO, - "Could not write to fixed event enable register %X", Event)); + "Could not write to fixed event enable register 0x%X", Event)); } else { @@ -368,7 +428,7 @@ AcpiInstallNotifyHandler ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (Device); + Node = AcpiNsValidateHandle (Device); if (!Node) { Status = AE_BAD_PARAMETER; @@ -555,7 +615,7 @@ AcpiRemoveNotifyHandler ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (Device); + Node = AcpiNsValidateHandle (Device); if (!Node) { Status = AE_BAD_PARAMETER; @@ -691,11 +751,11 @@ AcpiInstallGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, - ACPI_EVENT_HANDLER Address, + ACPI_GPE_HANDLER Address, void *Context) { ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_HANDLER_INFO *Handler; + ACPI_GPE_HANDLER_INFO *Handler; ACPI_STATUS Status; ACPI_CPU_FLAGS Flags; @@ -705,7 +765,7 @@ AcpiInstallGpeHandler ( /* Parameter validation */ - if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) + if ((!Address) || (Type & ~ACPI_GPE_XRUPT_TYPE_MASK)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -716,13 +776,24 @@ AcpiInstallGpeHandler ( return_ACPI_STATUS (Status); } + /* Allocate and init handler object (before lock) */ + + Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + /* Ensure that we have a valid GPE number */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); if (!GpeEventInfo) { Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + goto FreeAndExit; } /* Make sure that there isn't a handler there already */ @@ -731,36 +802,40 @@ AcpiInstallGpeHandler ( ACPI_GPE_DISPATCH_HANDLER) { Status = AE_ALREADY_EXISTS; - goto UnlockAndExit; + goto FreeAndExit; } - /* Allocate and init handler object */ + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + Handler->OriginalFlags = (UINT8) (GpeEventInfo->Flags & + (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK)); - Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_HANDLER_INFO)); - if (!Handler) + /* + * If the GPE is associated with a method, it may have been enabled + * automatically during initialization, in which case it has to be + * disabled now to avoid spurious execution of the handler. + */ + if (((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) || + (Handler->OriginalFlags & ACPI_GPE_DISPATCH_NOTIFY)) && + GpeEventInfo->RuntimeCount) { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } + Handler->OriginallyEnabled = TRUE; + (void) AcpiEvRemoveGpeReference (GpeEventInfo); - Handler->Address = Address; - Handler->Context = Context; - Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + /* Sanity check of original type against new type */ - /* Disable the GPE before installing the handler */ - - Status = AcpiEvDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; + if (Type != (UINT32) (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK)) + { + ACPI_WARNING ((AE_INFO, "GPE type mismatch (level/edge)")); + } } /* Install the handler */ - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); GpeEventInfo->Dispatch.Handler = Handler; - /* Setup up dispatch flags to indicate handler (vs. method) */ + /* Setup up dispatch flags to indicate handler (vs. method/notify) */ GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); @@ -771,6 +846,11 @@ AcpiInstallGpeHandler ( UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); + +FreeAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + ACPI_FREE (Handler); + goto UnlockAndExit; } ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler) @@ -795,10 +875,10 @@ ACPI_STATUS AcpiRemoveGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - ACPI_EVENT_HANDLER Address) + ACPI_GPE_HANDLER Address) { ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_HANDLER_INFO *Handler; + ACPI_GPE_HANDLER_INFO *Handler; ACPI_STATUS Status; ACPI_CPU_FLAGS Flags; @@ -819,6 +899,8 @@ AcpiRemoveGpeHandler ( return_ACPI_STATUS (Status); } + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + /* Ensure that we have a valid GPE number */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); @@ -845,28 +927,27 @@ AcpiRemoveGpeHandler ( goto UnlockAndExit; } - /* Disable the GPE before removing the handler */ - - Status = AcpiEvDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - /* Remove the handler */ - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); Handler = GpeEventInfo->Dispatch.Handler; /* Restore Method node (if any), set dispatch flags */ GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode; - GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ - if (Handler->MethodNode) + GpeEventInfo->Flags &= + ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); + GpeEventInfo->Flags |= Handler->OriginalFlags; + + /* + * If the GPE was previously associated with a method and it was + * enabled, it should be enabled at this point to restore the + * post-initialization configuration. + */ + if ((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) && + Handler->OriginallyEnabled) { - GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; + (void) AcpiEvAddGpeReference (GpeEventInfo); } - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Now we can free the handler object */ @@ -874,6 +955,7 @@ AcpiRemoveGpeHandler ( UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica-unix/events/evxfevnt.c b/sys/contrib/dev/acpica-unix/events/evxfevnt.c index bc24f18c51..437f6e3137 100644 --- a/sys/contrib/dev/acpica-unix/events/evxfevnt.c +++ b/sys/contrib/dev/acpica-unix/events/evxfevnt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -118,21 +118,11 @@ #include "acpi.h" #include "accommon.h" -#include "acevents.h" -#include "acnamesp.h" #include "actables.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfevnt") -/* Local prototypes */ - -static ACPI_STATUS -AcpiEvGetGpeDevice ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context); - /******************************************************************************* * @@ -305,187 +295,11 @@ AcpiEnableEvent ( ACPI_EXPORT_SYMBOL (AcpiEnableEvent) -/******************************************************************************* - * - * FUNCTION: AcpiSetGpeType - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Type - New GPE type - * - * RETURN: Status - * - * DESCRIPTION: Set the type of an individual GPE - * - ******************************************************************************/ - -ACPI_STATUS -AcpiSetGpeType ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT8 Type) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiSetGpeType); - - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) - { - return_ACPI_STATUS (AE_OK); - } - - /* Set the new type (will disable GPE if currently enabled) */ - - Status = AcpiEvSetGpeType (GpeEventInfo, Type); - -UnlockAndExit: - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiSetGpeType) - - -/******************************************************************************* - * - * FUNCTION: AcpiEnableGpe - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Just enable, or also wake enable? - * Called from ISR or not - * - * RETURN: Status - * - * DESCRIPTION: Enable an ACPI event (general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEnableGpe ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiEnableGpe); - - - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Perform the enable */ - - Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); - -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiEnableGpe) - - -/******************************************************************************* - * - * FUNCTION: AcpiDisableGpe - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Just disable, or also wake disable? - * Called from ISR or not - * - * RETURN: Status - * - * DESCRIPTION: Disable an ACPI event (general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDisableGpe ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiDisableGpe); - - - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - Status = AcpiEvDisableGpe (GpeEventInfo); - -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiDisableGpe) - - /******************************************************************************* * * FUNCTION: AcpiDisableEvent * - * PARAMETERS: Event - The fixed eventto be enabled + * PARAMETERS: Event - The fixed event to be disabled * Flags - Reserved * * RETURN: Status @@ -588,66 +402,6 @@ AcpiClearEvent ( ACPI_EXPORT_SYMBOL (AcpiClearEvent) -/******************************************************************************* - * - * FUNCTION: AcpiClearGpe - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Called from an ISR or not - * - * RETURN: Status - * - * DESCRIPTION: Clear an ACPI event (general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiClearGpe ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiClearGpe); - - - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - Status = AcpiHwClearGpe (GpeEventInfo); - -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiClearGpe) - - /******************************************************************************* * * FUNCTION: AcpiGetEventStatus @@ -696,417 +450,3 @@ AcpiGetEventStatus ( ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) -/******************************************************************************* - * - * FUNCTION: AcpiGetGpeStatus - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Called from an ISR or not - * EventStatus - Where the current status of the event will - * be returned - * - * RETURN: Status - * - * DESCRIPTION: Get status of an event (general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetGpeStatus ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags, - ACPI_EVENT_STATUS *EventStatus) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); - - - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Obtain status on the requested GPE number */ - - Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); - -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) - - -/******************************************************************************* - * - * FUNCTION: AcpiInstallGpeBlock - * - * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device - * GpeBlockAddress - Address and SpaceID - * RegisterCount - Number of GPE register pairs in the block - * InterruptNumber - H/W interrupt for the block - * - * RETURN: Status - * - * DESCRIPTION: Create and Install a block of GPE registers - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallGpeBlock ( - ACPI_HANDLE GpeDevice, - ACPI_GENERIC_ADDRESS *GpeBlockAddress, - UINT32 RegisterCount, - UINT32 InterruptNumber) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_GPE_BLOCK_INFO *GpeBlock; - - - ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock); - - - if ((!GpeDevice) || - (!GpeBlockAddress) || - (!RegisterCount)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Node = AcpiNsMapHandleToNode (GpeDevice); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* - * For user-installed GPE Block Devices, the GpeBlockBaseNumber - * is always zero - */ - Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, - 0, InterruptNumber, &GpeBlock); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Run the _PRW methods and enable the GPEs */ - - Status = AcpiEvInitializeGpeBlock (Node, GpeBlock); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Get the DeviceObject attached to the node */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc) - { - /* No object, create a new one */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } - - /* Install the GPE block in the DeviceObject */ - - ObjDesc->Device.GpeBlock = GpeBlock; - - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock) - - -/******************************************************************************* - * - * FUNCTION: AcpiRemoveGpeBlock - * - * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device - * - * RETURN: Status - * - * DESCRIPTION: Remove a previously installed block of GPE registers - * - ******************************************************************************/ - -ACPI_STATUS -AcpiRemoveGpeBlock ( - ACPI_HANDLE GpeDevice) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - - - ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock); - - - if (!GpeDevice) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Node = AcpiNsMapHandleToNode (GpeDevice); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Get the DeviceObject attached to the node */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc || - !ObjDesc->Device.GpeBlock) - { - return_ACPI_STATUS (AE_NULL_OBJECT); - } - - /* Delete the GPE block (but not the DeviceObject) */ - - Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock); - if (ACPI_SUCCESS (Status)) - { - ObjDesc->Device.GpeBlock = NULL; - } - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - -ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) - - -/******************************************************************************* - * - * FUNCTION: AcpiGetGpeDevice - * - * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) - * GpeDevice - Where the parent GPE Device is returned - * - * RETURN: Status - * - * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL - * gpe device indicates that the gpe number is contained in one of - * the FADT-defined gpe blocks. Otherwise, the GPE block device. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiGetGpeDevice ( - UINT32 Index, - ACPI_HANDLE *GpeDevice) -{ - ACPI_GPE_DEVICE_INFO Info; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); - - - if (!GpeDevice) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (Index >= AcpiCurrentGpeCount) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } - - /* Setup and walk the GPE list */ - - Info.Index = Index; - Info.Status = AE_NOT_EXIST; - Info.GpeDevice = NULL; - Info.NextBlockBaseIndex = 0; - - Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); - return_ACPI_STATUS (Info.Status); -} - -ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGetGpeDevice - * - * PARAMETERS: GPE_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE - * block device. NULL if the GPE is one of the FADT-defined GPEs. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvGetGpeDevice ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context) -{ - ACPI_GPE_DEVICE_INFO *Info = Context; - - - /* Increment Index by the number of GPEs in this block */ - - Info->NextBlockBaseIndex += - (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH); - - if (Info->Index < Info->NextBlockBaseIndex) - { - /* - * The GPE index is within this block, get the node. Leave the node - * NULL for the FADT-defined GPEs - */ - if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) - { - Info->GpeDevice = GpeBlock->Node; - } - - Info->Status = AE_OK; - return (AE_CTRL_END); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiDisableAllGpes - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Disable and clear all GPEs in all GPE blocks - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDisableAllGpes ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiHwDisableAllGpes (); - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEnableAllRuntimeGpes - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEnableAllRuntimeGpes ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiHwEnableAllRuntimeGpes (); - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - - return_ACPI_STATUS (Status); -} - - diff --git a/sys/contrib/dev/acpica-unix/events/evxfevnt.c b/sys/contrib/dev/acpica-unix/events/evxfgpe.c similarity index 61% copy from sys/contrib/dev/acpica-unix/events/evxfevnt.c copy to sys/contrib/dev/acpica-unix/events/evxfgpe.c index bc24f18c51..61c4c2e31e 100644 --- a/sys/contrib/dev/acpica-unix/events/evxfevnt.c +++ b/sys/contrib/dev/acpica-unix/events/evxfgpe.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs) * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,224 +114,199 @@ *****************************************************************************/ -#define __EVXFEVNT_C__ +#define __EVXFGPE_C__ #include "acpi.h" #include "accommon.h" #include "acevents.h" #include "acnamesp.h" -#include "actables.h" #define _COMPONENT ACPI_EVENTS - ACPI_MODULE_NAME ("evxfevnt") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiEvGetGpeDevice ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context); + ACPI_MODULE_NAME ("evxfgpe") /******************************************************************************* * - * FUNCTION: AcpiEnable + * FUNCTION: AcpiUpdateAllGpes * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Transfers the system into ACPI mode. + * DESCRIPTION: Complete GPE initialization and enable all GPEs that have + * associated _Lxx or _Exx methods and are not pointed to by any + * device _PRW methods (this indicates that these GPEs are + * generally intended for system or device wakeup. Such GPEs + * have to be enabled directly when the devices whose _PRW + * methods point to them are set up for wakeup signaling.) + * + * NOTE: Should be called after any GPEs are added to the system. Primarily, + * after the system _PRW methods have been run, but also after a GPE Block + * Device has been added or if any new GPE methods have been added via a + * dynamic table load. * ******************************************************************************/ ACPI_STATUS -AcpiEnable ( +AcpiUpdateAllGpes ( void) { - ACPI_STATUS Status = AE_OK; - + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE (AcpiEnable); + ACPI_FUNCTION_TRACE (AcpiUpdateGpes); - /* ACPI tables must be present */ - if (!AcpiTbTablesLoaded ()) + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + return_ACPI_STATUS (Status); } - /* Check current mode */ - - if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) + if (AcpiGbl_AllGpesInitialized) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); + goto UnlockAndExit; } - else - { - /* Transition to ACPI mode */ - Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); - return_ACPI_STATUS (Status); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Transition to ACPI mode successful\n")); + Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL); + if (ACPI_SUCCESS (Status)) + { + AcpiGbl_AllGpesInitialized = TRUE; } +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiEnable) +ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes) /******************************************************************************* * - * FUNCTION: AcpiDisable + * FUNCTION: AcpiEnableGpe * - * PARAMETERS: None + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block * * RETURN: Status * - * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. + * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is + * hardware-enabled. * ******************************************************************************/ ACPI_STATUS -AcpiDisable ( - void) +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) { - ACPI_STATUS Status = AE_OK; - + ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiDisable); + ACPI_FUNCTION_TRACE (AcpiEnableGpe); - if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "System is already in legacy (non-ACPI) mode\n")); - } - else - { - /* Transition to LEGACY mode */ - Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not exit ACPI mode to legacy mode")); - return_ACPI_STATUS (Status); - } + /* Ensure that we have a valid GPE number */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) + { + Status = AcpiEvAddGpeReference (GpeEventInfo); } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiDisable) +ACPI_EXPORT_SYMBOL (AcpiEnableGpe) /******************************************************************************* * - * FUNCTION: AcpiEnableEvent + * FUNCTION: AcpiDisableGpe * - * PARAMETERS: Event - The fixed eventto be enabled - * Flags - Reserved + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block * * RETURN: Status * - * DESCRIPTION: Enable an ACPI event (fixed) + * DESCRIPTION: Remove a reference to a GPE. When the last reference is + * removed, only then is the GPE disabled (for runtime GPEs), or + * the GPE mask bit disabled (for wake GPEs) * ******************************************************************************/ ACPI_STATUS -AcpiEnableEvent ( - UINT32 Event, - UINT32 Flags) +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) { - ACPI_STATUS Status = AE_OK; - UINT32 Value; - - - ACPI_FUNCTION_TRACE (AcpiEnableEvent); - + ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_CPU_FLAGS Flags; - /* Decode the Fixed Event */ - if (Event > ACPI_EVENT_MAX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + ACPI_FUNCTION_TRACE (AcpiDisableGpe); - /* - * Enable the requested fixed event (by writing a one to the enable - * register bit) - */ - Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_ENABLE_EVENT); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* Make sure that the hardware responded */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Ensure that we have a valid GPE number */ - if (Value != 1) + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) { - ACPI_ERROR ((AE_INFO, - "Could not enable %s event", AcpiUtGetEventName (Event))); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + Status = AcpiEvRemoveGpeReference (GpeEventInfo); } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiEnableEvent) +ACPI_EXPORT_SYMBOL (AcpiDisableGpe) /******************************************************************************* * - * FUNCTION: AcpiSetGpeType + * FUNCTION: AcpiSetGpe * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Type - New GPE type + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE * * RETURN: Status * - * DESCRIPTION: Set the type of an individual GPE + * DESCRIPTION: Enable or disable an individual GPE. This function bypasses + * the reference count mechanism used in the AcpiEnableGpe and + * AcpiDisableGpe interfaces -- and should be used with care. + * + * Note: Typically used to disable a runtime GPE for short period of time, + * then re-enable it, without disturbing the existing reference counts. This + * is useful, for example, in the Embedded Controller (EC) driver. * ******************************************************************************/ ACPI_STATUS -AcpiSetGpeType ( +AcpiSetGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - UINT8 Type) + UINT8 Action) { - ACPI_STATUS Status = AE_OK; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiSetGpeType); + ACPI_FUNCTION_TRACE (AcpiSetGpe); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + /* Ensure that we have a valid GPE number */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); @@ -341,290 +316,331 @@ AcpiSetGpeType ( goto UnlockAndExit; } - if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) + /* Perform the action */ + + switch (Action) { - return_ACPI_STATUS (AE_OK); - } + case ACPI_GPE_ENABLE: + Status = AcpiEvEnableGpe (GpeEventInfo); + break; - /* Set the new type (will disable GPE if currently enabled) */ + case ACPI_GPE_DISABLE: + Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + break; - Status = AcpiEvSetGpeType (GpeEventInfo, Type); + default: + Status = AE_BAD_PARAMETER; + break; + } UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiSetGpeType) +ACPI_EXPORT_SYMBOL (AcpiSetGpe) /******************************************************************************* * - * FUNCTION: AcpiEnableGpe + * FUNCTION: AcpiSetupGpeForWake * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Just enable, or also wake enable? - * Called from ISR or not + * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW) + * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block * * RETURN: Status * - * DESCRIPTION: Enable an ACPI event (general purpose) + * DESCRIPTION: Mark a GPE as having the ability to wake the system. This + * interface is intended to be used as the host executes the + * _PRW methods (Power Resources for Wake) in the system tables. + * Each _PRW appears under a Device Object (The WakeDevice), and + * contains the info for the wake GPE associated with the + * WakeDevice. * ******************************************************************************/ ACPI_STATUS -AcpiEnableGpe ( +AcpiSetupGpeForWake ( + ACPI_HANDLE WakeDevice, ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) + UINT32 GpeNumber) { - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status = AE_BAD_PARAMETER; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiEnableGpe); + ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake); - /* Use semaphore lock if not executing at interrupt level */ + /* Parameter Validation */ - if (Flags & ACPI_NOT_ISR) + if (!WakeDevice) { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* + * By forcing WakeDevice to be valid, we automatically enable the + * implicit notify feature on all hosts. + */ + return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Ensure that we have a valid GPE number */ + /* Validate WakeDevice is of type Device */ - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) + DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice); + if (DeviceNode->Type != ACPI_TYPE_DEVICE) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Perform the enable */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); + /* Ensure that we have a valid GPE number */ -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + /* + * If there is no method or handler for this GPE, then the + * WakeDevice will be notified whenever this GPE fires (aka + * "implicit notify") Note: The GPE is assumed to be + * level-triggered (for windows compatibility). + */ + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_NONE) + { + GpeEventInfo->Flags = + (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED); + GpeEventInfo->Dispatch.DeviceNode = DeviceNode; + } + + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; + Status = AE_OK; } + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiEnableGpe) +ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake) /******************************************************************************* * - * FUNCTION: AcpiDisableGpe + * FUNCTION: AcpiSetGpeWakeMask * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Just disable, or also wake disable? - * Called from ISR or not + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * Action - Enable or Disable * * RETURN: Status * - * DESCRIPTION: Disable an ACPI event (general purpose) + * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must + * already be marked as a WAKE GPE. * ******************************************************************************/ ACPI_STATUS -AcpiDisableGpe ( +AcpiSetGpeWakeMask ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - UINT32 Flags) + UINT8 Action) { ACPI_STATUS Status = AE_OK; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_CPU_FLAGS Flags; + UINT32 RegisterBit; - ACPI_FUNCTION_TRACE (AcpiDisableGpe); + ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask); - /* Use semaphore lock if not executing at interrupt level */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (Flags & ACPI_NOT_ISR) + /* + * Ensure that we have a valid GPE number and that this GPE is in + * fact a wake GPE + */ + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - /* Ensure that we have a valid GPE number */ + if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) { - Status = AE_BAD_PARAMETER; + Status = AE_NOT_EXIST; goto UnlockAndExit; } - Status = AcpiEvDisableGpe (GpeEventInfo); + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) + /* Perform the action */ + + switch (Action) { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + case ACPI_GPE_ENABLE: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit); + break; + + case ACPI_GPE_DISABLE: + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit); + break; + + default: + ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action)); + Status = AE_BAD_PARAMETER; + break; } + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiDisableGpe) +ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask) /******************************************************************************* * - * FUNCTION: AcpiDisableEvent + * FUNCTION: AcpiClearGpe * - * PARAMETERS: Event - The fixed eventto be enabled - * Flags - Reserved + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block * * RETURN: Status * - * DESCRIPTION: Disable an ACPI event (fixed) + * DESCRIPTION: Clear an ACPI event (general purpose) * ******************************************************************************/ ACPI_STATUS -AcpiDisableEvent ( - UINT32 Event, - UINT32 Flags) +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) { ACPI_STATUS Status = AE_OK; - UINT32 Value; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiDisableEvent); + ACPI_FUNCTION_TRACE (AcpiClearGpe); - /* Decode the Fixed Event */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (Event > ACPI_EVENT_MAX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Disable the requested fixed event (by writing a zero to the enable - * register bit) - */ - Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - ACPI_DISABLE_EVENT); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Ensure that we have a valid GPE number */ - Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); - if (ACPI_FAILURE (Status)) + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) { - return_ACPI_STATUS (Status); + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - if (Value != 0) - { - ACPI_ERROR ((AE_INFO, - "Could not disable %s events", AcpiUtGetEventName (Event))); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); - } + Status = AcpiHwClearGpe (GpeEventInfo); +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiDisableEvent) +ACPI_EXPORT_SYMBOL (AcpiClearGpe) /******************************************************************************* * - * FUNCTION: AcpiClearEvent + * FUNCTION: AcpiGetGpeStatus * - * PARAMETERS: Event - The fixed event to be cleared + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * EventStatus - Where the current status of the event + * will be returned * * RETURN: Status * - * DESCRIPTION: Clear an ACPI event (fixed) + * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled) * ******************************************************************************/ ACPI_STATUS -AcpiClearEvent ( - UINT32 Event) +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_STATUS *EventStatus) { ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiClearEvent); + ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); - /* Decode the Fixed Event */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (Event > ACPI_EVENT_MAX) + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - /* - * Clear the requested fixed event (By writing a one to the status - * register bit) - */ - Status = AcpiWriteBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - ACPI_CLEAR_STATUS); + /* Obtain status on the requested GPE number */ + + Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiClearEvent) +ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) /******************************************************************************* * - * FUNCTION: AcpiClearGpe + * FUNCTION: AcpiFinishGpe * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Called from an ISR or not + * PARAMETERS: GpeDevice - Namespace node for the GPE Block + * (NULL for FADT defined GPEs) + * GpeNumber - GPE level within the GPE block * * RETURN: Status * - * DESCRIPTION: Clear an ACPI event (general purpose) + * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE + * processing. Intended for use by asynchronous host-installed + * GPE handlers. The GPE is only reenabled if the EnableForRun bit + * is set in the GPE info. * ******************************************************************************/ ACPI_STATUS -AcpiClearGpe ( +AcpiFinishGpe ( ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) + UINT32 GpeNumber) { - ACPI_STATUS Status = AE_OK; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE (AcpiClearGpe); + ACPI_FUNCTION_TRACE (AcpiFinishGpe); - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); /* Ensure that we have a valid GPE number */ @@ -635,130 +651,88 @@ AcpiClearGpe ( goto UnlockAndExit; } - Status = AcpiHwClearGpe (GpeEventInfo); + Status = AcpiEvFinishGpe (GpeEventInfo); UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiClearGpe) +ACPI_EXPORT_SYMBOL (AcpiFinishGpe) -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiGetEventStatus + * FUNCTION: AcpiDisableAllGpes * - * PARAMETERS: Event - The fixed event - * EventStatus - Where the current status of the event will - * be returned + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Obtains and returns the current status of the event + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks * ******************************************************************************/ ACPI_STATUS -AcpiGetEventStatus ( - UINT32 Event, - ACPI_EVENT_STATUS *EventStatus) +AcpiDisableAllGpes ( + void) { - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (AcpiGetEventStatus); + ACPI_STATUS Status; - if (!EventStatus) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); - /* Decode the Fixed Event */ - if (Event > ACPI_EVENT_MAX) + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (Status); } - /* Get the status of the requested fixed event */ - - Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); + Status = AcpiHwDisableAllGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) +ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes) -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiGetGpeStatus + * FUNCTION: AcpiEnableAllRuntimeGpes * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Called from an ISR or not - * EventStatus - Where the current status of the event will - * be returned + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Get status of an event (general purpose) + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks * ******************************************************************************/ ACPI_STATUS -AcpiGetGpeStatus ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags, - ACPI_EVENT_STATUS *EventStatus) +AcpiEnableAllRuntimeGpes ( + void) { - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); - + ACPI_STATUS Status; - /* Use semaphore lock if not executing at interrupt level */ - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); - /* Ensure that we have a valid GPE number */ - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; + return_ACPI_STATUS (Status); } - /* Obtain status on the requested GPE number */ - - Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); + Status = AcpiHwEnableAllRuntimeGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) +ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes) /******************************************************************************* @@ -772,7 +746,8 @@ ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) * * RETURN: Status * - * DESCRIPTION: Create and Install a block of GPE registers + * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not + * enabled here. * ******************************************************************************/ @@ -805,7 +780,7 @@ AcpiInstallGpeBlock ( return (Status); } - Node = AcpiNsMapHandleToNode (GpeDevice); + Node = AcpiNsValidateHandle (GpeDevice); if (!Node) { Status = AE_BAD_PARAMETER; @@ -823,21 +798,15 @@ AcpiInstallGpeBlock ( goto UnlockAndExit; } - /* Run the _PRW methods and enable the GPEs */ - - Status = AcpiEvInitializeGpeBlock (Node, GpeBlock); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Get the DeviceObject attached to the node */ + /* Install block in the DeviceObject attached to the node */ ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { - /* No object, create a new one */ - + /* + * No object, create a new one (Device nodes do not always have + * an attached object) + */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE); if (!ObjDesc) { @@ -850,14 +819,13 @@ AcpiInstallGpeBlock ( /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); - if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } } - /* Install the GPE block in the DeviceObject */ + /* Now install the GPE block in the DeviceObject */ ObjDesc->Device.GpeBlock = GpeBlock; @@ -905,7 +873,7 @@ AcpiRemoveGpeBlock ( return (Status); } - Node = AcpiNsMapHandleToNode (GpeDevice); + Node = AcpiNsValidateHandle (GpeDevice); if (!Node) { Status = AE_BAD_PARAMETER; @@ -992,121 +960,3 @@ AcpiGetGpeDevice ( } ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGetGpeDevice - * - * PARAMETERS: GPE_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE - * block device. NULL if the GPE is one of the FADT-defined GPEs. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvGetGpeDevice ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context) -{ - ACPI_GPE_DEVICE_INFO *Info = Context; - - - /* Increment Index by the number of GPEs in this block */ - - Info->NextBlockBaseIndex += - (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH); - - if (Info->Index < Info->NextBlockBaseIndex) - { - /* - * The GPE index is within this block, get the node. Leave the node - * NULL for the FADT-defined GPEs - */ - if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) - { - Info->GpeDevice = GpeBlock->Node; - } - - Info->Status = AE_OK; - return (AE_CTRL_END); - } - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiDisableAllGpes - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Disable and clear all GPEs in all GPE blocks - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDisableAllGpes ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiHwDisableAllGpes (); - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEnableAllRuntimeGpes - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEnableAllRuntimeGpes ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiHwEnableAllRuntimeGpes (); - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - - return_ACPI_STATUS (Status); -} - - diff --git a/sys/contrib/dev/acpica-unix/events/evxfregn.c b/sys/contrib/dev/acpica-unix/events/evxfregn.c index d4f499130a..dde27f8d73 100644 --- a/sys/contrib/dev/acpica-unix/events/evxfregn.c +++ b/sys/contrib/dev/acpica-unix/events/evxfregn.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -139,6 +139,12 @@ * * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. * + * NOTE: This function should only be called after AcpiEnableSubsystem has + * been called. This is because any _REG methods associated with the Space ID + * are executed here, and these methods can only be safely executed after + * the default handlers have been installed and the hardware has been + * initialized (via AcpiEnableSubsystem.) + * ******************************************************************************/ ACPI_STATUS @@ -171,7 +177,7 @@ AcpiInstallAddressSpaceHandler ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (Device); + Node = AcpiNsValidateHandle (Device); if (!Node) { Status = AE_BAD_PARAMETER; @@ -186,9 +192,41 @@ AcpiInstallAddressSpaceHandler ( goto UnlockAndExit; } - /* Run all _REG methods for this address space */ + /* + * For the default SpaceIDs, (the IDs for which there are default region handlers + * installed) Only execute the _REG methods if the global initialization _REG + * methods have already been run (via AcpiInitializeObjects). In other words, + * we will defer the execution of the _REG methods for these SpaceIDs until + * execution of AcpiInitializeObjects. This is done because we need the handlers + * for the default spaces (mem/io/pci/table) to be installed before we can run + * any control methods (or _REG methods). There is known BIOS code that depends + * on this. + * + * For all other SpaceIDs, we can safely execute the _REG methods immediately. + * This means that for IDs like EmbeddedController, this function should be called + * only after AcpiEnableSubsystem has been called. + */ + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + case ACPI_ADR_SPACE_SYSTEM_IO: + case ACPI_ADR_SPACE_PCI_CONFIG: + case ACPI_ADR_SPACE_DATA_TABLE: + + if (AcpiGbl_RegMethodsExecuted) + { + /* Run all _REG methods for this address space */ + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); + } + break; + + default: + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); + break; + } - Status = AcpiEvExecuteRegMethods (Node, SpaceId); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -244,7 +282,7 @@ AcpiRemoveAddressSpaceHandler ( /* Convert and validate the device handle */ - Node = AcpiNsMapHandleToNode (Device); + Node = AcpiNsValidateHandle (Device); if (!Node || ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_PROCESSOR) && diff --git a/sys/contrib/dev/acpica-unix/executer/exconfig.c b/sys/contrib/dev/acpica-unix/executer/exconfig.c index 5b48bef4b4..341a05bac3 100644 --- a/sys/contrib/dev/acpica-unix/executer/exconfig.c +++ b/sys/contrib/dev/acpica-unix/executer/exconfig.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -164,8 +164,9 @@ AcpiExAddTable ( ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { - ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (ExAddTable); @@ -196,9 +197,27 @@ AcpiExAddTable ( { AcpiUtRemoveReference (ObjDesc); *DdbHandle = NULL; + return_ACPI_STATUS (Status); } - return_ACPI_STATUS (Status); + /* Execute any module-level code that was found in the table */ + + AcpiExExitInterpreter (); + AcpiNsExecModuleCodeList (); + AcpiExEnterInterpreter (); + + /* + * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is + * responsible for discovering any new wake GPEs by running _PRW methods + * that may have been loaded by this table. + */ + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_SUCCESS (Status)) + { + AcpiEvUpdateGpes (OwnerId); + } + + return_ACPI_STATUS (AE_OK); } @@ -256,15 +275,13 @@ AcpiExLoadTableOp ( /* Table not found, return an Integer=0 and AE_OK */ - DdbHandle = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0); if (!DdbHandle) { return_ACPI_STATUS (AE_NO_MEMORY); } - DdbHandle->Integer.Value = 0; *ReturnDesc = DdbHandle; - return_ACPI_STATUS (AE_OK); } @@ -342,9 +359,8 @@ AcpiExLoadTableOp ( Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { - ACPI_INFO ((AE_INFO, - "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", - Table->Signature, Table->OemId, Table->OemTableId)); + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + AcpiTbPrintTableHeader (0, Table); } /* Invoke table handler if present */ @@ -382,7 +398,7 @@ AcpiExRegionRead ( UINT8 *Buffer) { ACPI_STATUS Status; - ACPI_INTEGER Value; + UINT64 Value; UINT32 RegionOffset = 0; UINT32 i; @@ -605,7 +621,10 @@ AcpiExLoadOp ( Status = AcpiTbAddTable (&TableDesc, &TableIndex); if (ACPI_FAILURE (Status)) { - goto Cleanup; + /* Delete allocated table buffer */ + + AcpiTbDeleteTable (&TableDesc); + return_ACPI_STATUS (Status); } /* @@ -636,6 +655,9 @@ AcpiExLoadOp ( return_ACPI_STATUS (Status); } + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + AcpiTbPrintTableHeader (0, TableDesc.Pointer); + /* Remove the reference by added by AcpiExStore above */ AcpiUtRemoveReference (DdbHandle); @@ -648,13 +670,6 @@ AcpiExLoadOp ( AcpiGbl_TableHandlerContext); } -Cleanup: - if (ACPI_FAILURE (Status)) - { - /* Delete allocated table buffer */ - - AcpiTbDeleteTable (&TableDesc); - } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica-unix/executer/exconvrt.c b/sys/contrib/dev/acpica-unix/executer/exconvrt.c index e7d8530329..67a0a26dce 100644 --- a/sys/contrib/dev/acpica-unix/executer/exconvrt.c +++ b/sys/contrib/dev/acpica-unix/executer/exconvrt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -129,7 +129,7 @@ static UINT32 AcpiExConvertToAscii ( - ACPI_INTEGER Integer, + UINT64 Integer, UINT16 Base, UINT8 *String, UINT8 MaxLength); @@ -158,7 +158,7 @@ AcpiExConvertToInteger ( { ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *Pointer; - ACPI_INTEGER Result; + UINT64 Result; UINT32 i; UINT32 Count; ACPI_STATUS Status; @@ -247,7 +247,7 @@ AcpiExConvertToInteger ( * Little endian is used, meaning that the first byte of the buffer * is the LSB of the integer */ - Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); + Result |= (((UINT64) Pointer[i]) << (i * 8)); } break; @@ -260,7 +260,7 @@ AcpiExConvertToInteger ( /* Create a new integer */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject (Result); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -271,7 +271,6 @@ AcpiExConvertToInteger ( /* Save the Result */ - ReturnDesc->Integer.Value = Result; AcpiExTruncateFor32bitTable (ReturnDesc); *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); @@ -390,12 +389,12 @@ AcpiExConvertToBuffer ( static UINT32 AcpiExConvertToAscii ( - ACPI_INTEGER Integer, + UINT64 Integer, UINT16 Base, UINT8 *String, UINT8 DataWidth) { - ACPI_INTEGER Digit; + UINT64 Digit; UINT32 i; UINT32 j; UINT32 k = 0; @@ -660,7 +659,7 @@ AcpiExConvertToString ( for (i = 0; i < ObjDesc->Buffer.Length; i++) { NewBuf += AcpiExConvertToAscii ( - (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1); *NewBuf++ = Separator; /* each separated by a comma or space */ } @@ -787,7 +786,7 @@ AcpiExConvertToTargetType ( default: - ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: %X", + ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X", DestinationType)); Status = AE_AML_INTERNAL; break; @@ -804,7 +803,7 @@ AcpiExConvertToTargetType ( default: ACPI_ERROR ((AE_INFO, - "Unknown Target type ID 0x%X AmlOpcode %X DestType %s", + "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s", GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), WalkState->Opcode, AcpiUtGetTypeName (DestinationType))); Status = AE_AML_INTERNAL; diff --git a/sys/contrib/dev/acpica-unix/executer/excreate.c b/sys/contrib/dev/acpica-unix/executer/excreate.c index e5463187a8..9c9071621d 100644 --- a/sys/contrib/dev/acpica-unix/executer/excreate.c +++ b/sys/contrib/dev/acpica-unix/executer/excreate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -402,11 +402,11 @@ AcpiExCreateRegion ( if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && (RegionSpace < ACPI_USER_REGION_BEGIN)) { - ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace)); + ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type 0x%X", RegionSpace)); return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); } - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", AcpiUtGetRegionName (RegionSpace), RegionSpace)); /* Create the region descriptor */ @@ -595,12 +595,10 @@ AcpiExCreateMethod ( ObjDesc->Method.AmlLength = AmlLength; /* - * Disassemble the method flags. Split off the Arg Count - * for efficiency + * Disassemble the method flags. Split off the ArgCount, Serialized + * flag, and SyncLevel for efficiency. */ MethodFlags = (UINT8) Operand[1]->Integer.Value; - - ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); /* @@ -609,6 +607,8 @@ AcpiExCreateMethod ( */ if (MethodFlags & AML_METHOD_SERIALIZED) { + ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED; + /* * ACPI 1.0: SyncLevel = 0 * ACPI 2.0: SyncLevel = SyncLevel in method declaration diff --git a/sys/contrib/dev/acpica-unix/executer/exstorob.c b/sys/contrib/dev/acpica-unix/executer/exdebug.c similarity index 54% copy from sys/contrib/dev/acpica-unix/executer/exstorob.c copy to sys/contrib/dev/acpica-unix/executer/exdebug.c index a1ad8d0aed..965db23850 100644 --- a/sys/contrib/dev/acpica-unix/executer/exstorob.c +++ b/sys/contrib/dev/acpica-unix/executer/exdebug.c @@ -1,7 +1,6 @@ - /****************************************************************************** * - * Module Name: exstorob - AML Interpreter object store support, store to object + * Module Name: exdebug - Support for stores to the AML Debug Object * *****************************************************************************/ @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,7 +113,7 @@ * *****************************************************************************/ -#define __EXSTOROB_C__ +#define __EXDEBUG_C__ #include "acpi.h" #include "accommon.h" @@ -122,181 +121,228 @@ #define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exstorob") + ACPI_MODULE_NAME ("exdebug") +#ifndef ACPI_NO_ERROR_MESSAGES /******************************************************************************* * - * FUNCTION: AcpiExStoreBufferToBuffer + * FUNCTION: AcpiExDoDebugObject + * + * PARAMETERS: SourceDesc - Object to be output to "Debug Object" + * Level - Indentation level (used for packages) + * Index - Current package element, zero if not pkg * - * PARAMETERS: SourceDesc - Source object to copy - * TargetDesc - Destination object of the copy + * RETURN: None * - * RETURN: Status + * DESCRIPTION: Handles stores to the AML Debug Object. For example: + * Store(INT1, Debug) * - * DESCRIPTION: Copy a buffer object to another buffer object. + * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set. + * + * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or + * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal + * operational case, stores to the debug object are ignored but can be easily + * enabled if necessary. * ******************************************************************************/ -ACPI_STATUS -AcpiExStoreBufferToBuffer ( +void +AcpiExDoDebugObject ( ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *TargetDesc) + UINT32 Level, + UINT32 Index) { - UINT32 Length; - UINT8 *Buffer; + UINT32 i; - ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); - /* We know that SourceDesc is a buffer by now */ + /* Output must be enabled via the DebugObject global or the DbgLevel */ - Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); - Length = SourceDesc->Buffer.Length; + if (!AcpiGbl_EnableAmlDebugObject && + !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT)) + { + return_VOID; + } /* - * If target is a buffer of length zero or is a static buffer, - * allocate a new buffer of the proper length + * Print line header as long as we are not in the middle of an + * object display */ - if ((TargetDesc->Buffer.Length == 0) || - (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) + if (!((Level > 0) && Index == 0)) { - TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); - if (!TargetDesc->Buffer.Pointer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } + AcpiOsPrintf ("[ACPI Debug] %*s", Level, " "); + } - TargetDesc->Buffer.Length = Length; + /* Display the index for package output only */ + + if (Index > 0) + { + AcpiOsPrintf ("(%.2u) ", Index-1); } - /* Copy source buffer to target buffer */ + if (!SourceDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return_VOID; + } - if (Length <= TargetDesc->Buffer.Length) + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) { - /* Clear existing buffer and copy in the new one */ - - ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); - -#ifdef ACPI_OBSOLETE_BEHAVIOR - /* - * NOTE: ACPI versions up to 3.0 specified that the buffer must be - * truncated if the string is smaller than the buffer. However, "other" - * implementations of ACPI never did this and thus became the defacto - * standard. ACPI 3.0A changes this behavior such that the buffer - * is no longer truncated. - */ - - /* - * OBSOLETE BEHAVIOR: - * If the original source was a string, we must truncate the buffer, - * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer - * copy must not truncate the original buffer. - */ - if (OriginalSrcType == ACPI_TYPE_STRING) - { - /* Set the new length of the target */ + AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc)); - TargetDesc->Buffer.Length = Length; + if (!AcpiUtValidInternalObject (SourceDesc)) + { + AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc); + return_VOID; } -#endif + } + else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + AcpiOsPrintf ("%s: %p\n", + AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), + SourceDesc); + return_VOID; } else { - /* Truncate the source, copy only what will fit */ + return_VOID; + } - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, - TargetDesc->Buffer.Length); + /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating source buffer from %X to %X\n", - Length, TargetDesc->Buffer.Length)); - } + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: - /* Copy flags */ + /* Output correct integer width */ - TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; - return_ACPI_STATUS (AE_OK); -} + if (AcpiGbl_IntegerByteWidth == 4) + { + AcpiOsPrintf ("0x%8.8X\n", + (UINT32) SourceDesc->Integer.Value); + } + else + { + AcpiOsPrintf ("0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value)); + } + break; + case ACPI_TYPE_BUFFER: -/******************************************************************************* - * - * FUNCTION: AcpiExStoreStringToString - * - * PARAMETERS: SourceDesc - Source object to copy - * TargetDesc - Destination object of the copy - * - * RETURN: Status - * - * DESCRIPTION: Copy a String object to another String object - * - ******************************************************************************/ + AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length); + AcpiUtDumpBuffer2 (SourceDesc->Buffer.Pointer, + (SourceDesc->Buffer.Length < 256) ? + SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY); + break; -ACPI_STATUS -AcpiExStoreStringToString ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *TargetDesc) -{ - UINT32 Length; - UINT8 *Buffer; + case ACPI_TYPE_STRING: + AcpiOsPrintf ("[0x%.2X] \"%s\"\n", + SourceDesc->String.Length, SourceDesc->String.Pointer); + break; - ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + case ACPI_TYPE_PACKAGE: + AcpiOsPrintf ("[Contains 0x%.2X Elements]\n", + SourceDesc->Package.Count); - /* We know that SourceDesc is a string by now */ + /* Output the entire contents of the package */ - Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); - Length = SourceDesc->String.Length; + for (i = 0; i < SourceDesc->Package.Count; i++) + { + AcpiExDoDebugObject (SourceDesc->Package.Elements[i], + Level+4, i+1); + } + break; - /* - * Replace existing string value if it will fit and the string - * pointer is not a static pointer (part of an ACPI table) - */ - if ((Length < TargetDesc->String.Length) && - (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) - { - /* - * String will fit in existing non-static buffer. - * Clear old string and copy in the new one - */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, - (ACPI_SIZE) TargetDesc->String.Length + 1); - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); - } - else - { - /* - * Free the current buffer, then allocate a new buffer - * large enough to hold the value - */ - if (TargetDesc->String.Pointer && - (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc)); + + /* Decode the reference */ + + switch (SourceDesc->Reference.Class) { - /* Only free if not a pointer into the DSDT */ + case ACPI_REFCLASS_INDEX: + + AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value); + break; + + case ACPI_REFCLASS_TABLE: + + /* Case for DdbHandle */ - ACPI_FREE (TargetDesc->String.Pointer); + AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value); + return; + + default: + break; } - TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( - (ACPI_SIZE) Length + 1); - if (!TargetDesc->String.Pointer) + AcpiOsPrintf (" "); + + /* Check for valid node first, then valid object */ + + if (SourceDesc->Reference.Node) { - return_ACPI_STATUS (AE_NO_MEMORY); + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != + ACPI_DESC_TYPE_NAMED) + { + AcpiOsPrintf (" %p - Not a valid namespace node\n", + SourceDesc->Reference.Node); + } + else + { + AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node, + (SourceDesc->Reference.Node)->Name.Ascii); + + switch ((SourceDesc->Reference.Node)->Type) + { + /* These types have no attached object */ + + case ACPI_TYPE_DEVICE: + AcpiOsPrintf ("Device\n"); + break; + + case ACPI_TYPE_THERMAL: + AcpiOsPrintf ("Thermal Zone\n"); + break; + + default: + AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, + Level+4, 0); + break; + } + } } + else if (SourceDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == + ACPI_DESC_TYPE_NAMED) + { + AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) + SourceDesc->Reference.Object)->Object, + Level+4, 0); + } + else + { + AcpiExDoDebugObject (SourceDesc->Reference.Object, + Level+4, 0); + } + } + break; - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; - ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); - } + default: - /* Set the new target length */ + AcpiOsPrintf ("%p\n", SourceDesc); + break; + } - TargetDesc->String.Length = Length; - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + return_VOID; } - - +#endif diff --git a/sys/contrib/dev/acpica-unix/executer/exdump.c b/sys/contrib/dev/acpica-unix/executer/exdump.c index 5078f250ad..44f7d3ba5a 100644 --- a/sys/contrib/dev/acpica-unix/executer/exdump.c +++ b/sys/contrib/dev/acpica-unix/executer/exdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -216,7 +216,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.MethodFlags), "Method Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.InfoFlags), "Info Flags"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, @@ -424,7 +424,6 @@ AcpiExDumpObject ( UINT8 *Target; char *Name; UINT8 Count; - const char *str; if (!Info) @@ -507,8 +506,8 @@ AcpiExDumpObject ( case ACPI_EXD_REFERENCE: - str = AcpiUtGetReferenceName (ObjDesc); - AcpiExOutString ("Class Name", __DECONST(char *, str)); + AcpiExOutString ("Class Name", + ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc))); AcpiExDumpReferenceObj (ObjDesc); break; @@ -865,7 +864,7 @@ AcpiExDumpOperands ( } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "**** Start operand dump for opcode [%s], %d operands\n", + "**** Start operand dump for opcode [%s], %u operands\n", OpcodeName, NumOperands)); if (NumOperands == 0) @@ -949,7 +948,7 @@ AcpiExDumpNamespaceNode ( AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); - AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); + AcpiExOutPointer ("Parent", Node->Parent); AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), AcpiExDumpNode); @@ -1097,7 +1096,7 @@ AcpiExDumpPackageObj ( case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("[Package] Contains %d Elements:\n", + AcpiOsPrintf ("[Package] Contains %u Elements:\n", ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) diff --git a/sys/contrib/dev/acpica-unix/executer/exfield.c b/sys/contrib/dev/acpica-unix/executer/exfield.c index 0065bb5184..3cec69aafc 100644 --- a/sys/contrib/dev/acpica-unix/executer/exfield.c +++ b/sys/contrib/dev/acpica-unix/executer/exfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -151,6 +151,7 @@ AcpiExReadDataFromField ( ACPI_OPERAND_OBJECT *BufferDesc; ACPI_SIZE Length; void *Buffer; + UINT32 Function; ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); @@ -183,13 +184,27 @@ AcpiExReadDataFromField ( } } else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus read. We must create a buffer to hold the data - * and directly access the region handler. + * This is an SMBus or IPMI read. We must create a buffer to hold + * the data and then directly access the region handler. + * + * Note: Smbus protocol value is passed in upper 16-bits of Function */ - BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_READ; + } + + BufferDesc = AcpiUtCreateBufferObject (Length); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -199,13 +214,11 @@ AcpiExReadDataFromField ( AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - /* - * Perform the read. - * Note: Smbus protocol value is passed in upper 16-bits of Function - */ + /* Call the region handler for the read */ + Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), - ACPI_READ | (ObjDesc->Field.Attribute << 16)); + ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), + Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -213,7 +226,7 @@ AcpiExReadDataFromField ( /* * Allocate a buffer for the contents of the field. * - * If the field is larger than the size of an ACPI_INTEGER, create + * If the field is larger than the current integer width, create * a BUFFER to hold it. Otherwise, use an INTEGER. This allows * the use of arithmetic operators on the returned value if the * field size is equal or smaller than an Integer. @@ -236,14 +249,13 @@ AcpiExReadDataFromField ( { /* Field will fit within an Integer (normal case) */ - BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } Length = AcpiGbl_IntegerByteWidth; - BufferDesc->Integer.Value = 0; Buffer = &BufferDesc->Integer.Value; } @@ -304,6 +316,7 @@ AcpiExWriteDataToField ( UINT32 Length; void *Buffer; ACPI_OPERAND_OBJECT *BufferDesc; + UINT32 Function; ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); @@ -332,40 +345,59 @@ AcpiExWriteDataToField ( } } else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && - (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) { /* - * This is an SMBus write. We will bypass the entire field mechanism - * and handoff the buffer directly to the handler. + * This is an SMBus or IPMI write. We will bypass the entire field + * mechanism and handoff the buffer directly to the handler. For + * these address spaces, the buffer is bi-directional; on a write, + * return data is returned in the same buffer. + * + * Source must be a buffer of sufficient size: + * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE. * - * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). + * Note: SMBus protocol type is passed in upper 16-bits of Function */ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) { - ACPI_ERROR ((AE_INFO, "SMBus write requires Buffer, found type %s", + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer, found type %s", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - if (SourceDesc->Buffer.Length < ACPI_SMBUS_BUFFER_SIZE) + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_WRITE; + } + + if (SourceDesc->Buffer.Length < Length) { ACPI_ERROR ((AE_INFO, - "SMBus write requires Buffer of length %X, found length %X", - ACPI_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length)); + "SMBus or IPMI write requires Buffer of length %u, found length %u", + Length, SourceDesc->Buffer.Length)); return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); } - BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + /* Create the bi-directional buffer */ + + BufferDesc = AcpiUtCreateBufferObject (Length); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, - ACPI_SMBUS_BUFFER_SIZE); + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); /* Lock entire transaction if requested */ @@ -374,11 +406,9 @@ AcpiExWriteDataToField ( /* * Perform the write (returns status and perhaps data in the * same buffer) - * Note: SMBus protocol type is passed in upper 16-bits of Function. */ Status = AcpiExAccessRegion (ObjDesc, 0, - (ACPI_INTEGER *) Buffer, - ACPI_WRITE | (ObjDesc->Field.Attribute << 16)); + (UINT64 *) Buffer, Function); AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; diff --git a/sys/contrib/dev/acpica-unix/executer/exfldio.c b/sys/contrib/dev/acpica-unix/executer/exfldio.c index cfb02213aa..55aacef4a4 100644 --- a/sys/contrib/dev/acpica-unix/executer/exfldio.c +++ b/sys/contrib/dev/acpica-unix/executer/exfldio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -133,13 +133,13 @@ static ACPI_STATUS AcpiExFieldDatumIo ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, + UINT64 *Value, UINT32 ReadWrite); static BOOLEAN AcpiExRegisterOverflow ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Value); + UINT64 Value); static ACPI_STATUS AcpiExSetupRegion ( @@ -181,7 +181,7 @@ AcpiExSetupRegion ( if (RgnDesc->Common.Type != ACPI_TYPE_REGION) { - ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)", + ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", RgnDesc->Common.Type, AcpiUtGetObjectTypeName (RgnDesc))); @@ -202,12 +202,13 @@ AcpiExSetupRegion ( } /* - * Exit now for SMBus address space, it has a non-linear address space - * and the request cannot be directly validated + * Exit now for SMBus or IPMI address space, it has a non-linear + * address space and the request cannot be directly validated */ - if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_IPMI) { - /* SMBus has a non-linear address space */ + /* SMBus or IPMI has a non-linear address space */ return_ACPI_STATUS (AE_OK); } @@ -232,8 +233,7 @@ AcpiExSetupRegion ( * (Region length is specified in bytes) */ if (RgnDesc->Region.Length < - (ObjDesc->CommonField.BaseByteOffset + - FieldDatumByteOffset + + (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset + ObjDesc->CommonField.AccessByteWidth)) { if (AcpiGbl_EnableInterpreterSlack) @@ -261,7 +261,7 @@ AcpiExSetupRegion ( * byte, and a field with Dword access specified. */ ACPI_ERROR ((AE_INFO, - "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)", + "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.AccessByteWidth, AcpiUtGetNodeName (RgnDesc->Region.Node), @@ -273,7 +273,7 @@ AcpiExSetupRegion ( * exceeds region length, indicate an error */ ACPI_ERROR ((AE_INFO, - "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)", + "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, @@ -295,7 +295,7 @@ AcpiExSetupRegion ( * FieldDatumByteOffset - Byte offset of this datum within the * parent field * Value - Where to store value (must at least - * the size of ACPI_INTEGER) + * 64 bits) * Function - Read or Write flag plus other region- * dependent flags * @@ -309,7 +309,7 @@ ACPI_STATUS AcpiExAccessRegion ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, + UINT64 *Value, UINT32 Function) { ACPI_STATUS Status; @@ -370,14 +370,14 @@ AcpiExAccessRegion ( if (Status == AE_NOT_IMPLEMENTED) { ACPI_ERROR ((AE_INFO, - "Region %s(%X) not implemented", + "Region %s (ID=%u) not implemented", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); } else if (Status == AE_NOT_EXIST) { ACPI_ERROR ((AE_INFO, - "Region %s(%X) has no handler", + "Region %s (ID=%u) has no handler", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); } @@ -407,7 +407,7 @@ AcpiExAccessRegion ( static BOOLEAN AcpiExRegisterOverflow ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Value) + UINT64 Value) { if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) @@ -419,7 +419,7 @@ AcpiExRegisterOverflow ( return (FALSE); } - if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength)) + if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength)) { /* * The Value is larger than the maximum value that can fit into @@ -456,11 +456,11 @@ static ACPI_STATUS AcpiExFieldDatumIo ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, + UINT64 *Value, UINT32 ReadWrite) { ACPI_STATUS Status; - ACPI_INTEGER LocalValue; + UINT64 LocalValue; ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); @@ -542,7 +542,7 @@ AcpiExFieldDatumIo ( * the register */ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, - (ACPI_INTEGER) ObjDesc->BankField.Value)) + (UINT64) ObjDesc->BankField.Value)) { return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); } @@ -585,7 +585,7 @@ AcpiExFieldDatumIo ( * the register */ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, - (ACPI_INTEGER) ObjDesc->IndexField.Value)) + (UINT64) ObjDesc->IndexField.Value)) { return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); } @@ -614,7 +614,7 @@ AcpiExFieldDatumIo ( "Read from Data Register\n")); Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, - Value, sizeof (ACPI_INTEGER)); + Value, sizeof (UINT64)); } else { @@ -625,14 +625,14 @@ AcpiExFieldDatumIo ( ACPI_FORMAT_UINT64 (*Value))); Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, - Value, sizeof (ACPI_INTEGER)); + Value, sizeof (UINT64)); } break; default: - ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X", + ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u", ObjDesc->Common.Type)); Status = AE_AML_INTERNAL; break; @@ -643,14 +643,14 @@ AcpiExFieldDatumIo ( if (ReadWrite == ACPI_READ) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Read %8.8X%8.8X, Width %d\n", + "Value Read %8.8X%8.8X, Width %u\n", ACPI_FORMAT_UINT64 (*Value), ObjDesc->CommonField.AccessByteWidth)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Value Written %8.8X%8.8X, Width %d\n", + "Value Written %8.8X%8.8X, Width %u\n", ACPI_FORMAT_UINT64 (*Value), ObjDesc->CommonField.AccessByteWidth)); } @@ -678,13 +678,13 @@ AcpiExFieldDatumIo ( ACPI_STATUS AcpiExWriteWithUpdateRule ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Mask, - ACPI_INTEGER FieldValue, + UINT64 Mask, + UINT64 FieldValue, UINT32 FieldDatumByteOffset) { ACPI_STATUS Status = AE_OK; - ACPI_INTEGER MergedValue; - ACPI_INTEGER CurrentValue; + UINT64 MergedValue; + UINT64 CurrentValue; ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); @@ -696,7 +696,7 @@ AcpiExWriteWithUpdateRule ( /* If the mask is all ones, we don't need to worry about the update rule */ - if (Mask != ACPI_INTEGER_MAX) + if (Mask != ACPI_UINT64_MAX) { /* Decode the update rule */ @@ -742,7 +742,7 @@ AcpiExWriteWithUpdateRule ( default: ACPI_ERROR ((AE_INFO, - "Unknown UpdateRule value: %X", + "Unknown UpdateRule value: 0x%X", (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } @@ -786,13 +786,14 @@ AcpiExExtractFromField ( UINT32 BufferLength) { ACPI_STATUS Status; - ACPI_INTEGER RawDatum; - ACPI_INTEGER MergedDatum; + UINT64 RawDatum; + UINT64 MergedDatum; UINT32 FieldOffset = 0; UINT32 BufferOffset = 0; UINT32 BufferTailBits; UINT32 DatumCount; UINT32 FieldDatumCount; + UINT32 AccessBitWidth; UINT32 i; @@ -802,25 +803,45 @@ AcpiExExtractFromField ( /* Validate target buffer and clear it */ if (BufferLength < - ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) { ACPI_ERROR ((AE_INFO, - "Field size %X (bits) is too large for buffer (%X)", + "Field size %u (bits) is too large for buffer (%u)", ObjDesc->CommonField.BitLength, BufferLength)); return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } + ACPI_MEMSET (Buffer, 0, BufferLength); + AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); + + /* Handle the simple case here */ + + if ((ObjDesc->CommonField.StartFieldBitOffset == 0) && + (ObjDesc->CommonField.BitLength == AccessBitWidth)) + { + Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ); + return_ACPI_STATUS (Status); + } + +/* TBD: Move to common setup code */ + + /* Field algorithm is limited to sizeof(UINT64), truncate if needed */ + + if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64)) + { + ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64); + AccessBitWidth = sizeof (UINT64) * 8; + } /* Compute the number of datums (access width data items) */ DatumCount = ACPI_ROUND_UP_TO ( - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.AccessBitWidth); + ObjDesc->CommonField.BitLength, AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( - ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.AccessBitWidth); + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth); /* Priming read from the field */ @@ -853,12 +874,11 @@ AcpiExExtractFromField ( * This avoids the differences in behavior between different compilers * concerning shift values larger than the target data width. */ - if ((ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset < + ACPI_INTEGER_BIT_SIZE) { MergedDatum |= RawDatum << - (ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset); + (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); } if (i == DatumCount) @@ -878,8 +898,7 @@ AcpiExExtractFromField ( /* Mask off any extra bits in the last datum */ - BufferTailBits = ObjDesc->CommonField.BitLength % - ObjDesc->CommonField.AccessBitWidth; + BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth; if (BufferTailBits) { MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); @@ -915,19 +934,20 @@ AcpiExInsertIntoField ( void *Buffer, UINT32 BufferLength) { + void *NewBuffer; ACPI_STATUS Status; - ACPI_INTEGER Mask; - ACPI_INTEGER WidthMask; - ACPI_INTEGER MergedDatum; - ACPI_INTEGER RawDatum = 0; + UINT64 Mask; + UINT64 WidthMask; + UINT64 MergedDatum; + UINT64 RawDatum = 0; UINT32 FieldOffset = 0; UINT32 BufferOffset = 0; UINT32 BufferTailBits; UINT32 DatumCount; UINT32 FieldDatumCount; - UINT32 i; + UINT32 AccessBitWidth; UINT32 RequiredLength; - void *NewBuffer; + UINT32 i; ACPI_FUNCTION_TRACE (ExInsertIntoField); @@ -964,31 +984,41 @@ AcpiExInsertIntoField ( BufferLength = RequiredLength; } +/* TBD: Move to common setup code */ + + /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */ + if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64)) + { + ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64); + } + + AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); + /* * Create the bitmasks used for bit insertion. * Note: This if/else is used to bypass compiler differences with the * shift operator */ - if (ObjDesc->CommonField.AccessBitWidth == ACPI_INTEGER_BIT_SIZE) + if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE) { - WidthMask = ACPI_INTEGER_MAX; + WidthMask = ACPI_UINT64_MAX; } else { - WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth); + WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth); } Mask = WidthMask & - ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); /* Compute the number of datums (access width data items) */ DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.AccessBitWidth); + AccessBitWidth); FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.AccessBitWidth); + ObjDesc->CommonField.StartFieldBitOffset, + AccessBitWidth); /* Get initial Datum from the input buffer */ @@ -1023,12 +1053,11 @@ AcpiExInsertIntoField ( * This avoids the differences in behavior between different compilers * concerning shift values larger than the target data width. */ - if ((ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) < + ACPI_INTEGER_BIT_SIZE) { MergedDatum = RawDatum >> - (ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset); + (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); } else { @@ -1047,15 +1076,15 @@ AcpiExInsertIntoField ( BufferOffset += ObjDesc->CommonField.AccessByteWidth; ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; } /* Mask off any extra bits in the last datum */ BufferTailBits = (ObjDesc->CommonField.BitLength + - ObjDesc->CommonField.StartFieldBitOffset) % - ObjDesc->CommonField.AccessBitWidth; + ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth; if (BufferTailBits) { Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); diff --git a/sys/contrib/dev/acpica-unix/executer/exmisc.c b/sys/contrib/dev/acpica-unix/executer/exmisc.c index 41e4a9752e..41a6d3aadf 100644 --- a/sys/contrib/dev/acpica-unix/executer/exmisc.c +++ b/sys/contrib/dev/acpica-unix/executer/exmisc.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -183,7 +183,7 @@ AcpiExGetObjectReference ( default: - ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -201,7 +201,7 @@ AcpiExGetObjectReference ( default: - ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X", + ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X", ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); return_ACPI_STATUS (AE_TYPE); } @@ -373,7 +373,7 @@ AcpiExDoConcatenate ( break; default: - ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", Operand0->Common.Type)); Status = AE_AML_INTERNAL; } @@ -475,7 +475,7 @@ AcpiExDoConcatenate ( /* Invalid object type, should not happen here */ - ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", Operand0->Common.Type)); Status =AE_AML_INTERNAL; goto Cleanup; @@ -508,11 +508,11 @@ Cleanup: * ******************************************************************************/ -ACPI_INTEGER +UINT64 AcpiExDoMathOp ( UINT16 Opcode, - ACPI_INTEGER Integer0, - ACPI_INTEGER Integer1) + UINT64 Integer0, + UINT64 Integer1) { ACPI_FUNCTION_ENTRY (); @@ -615,8 +615,8 @@ AcpiExDoMathOp ( ACPI_STATUS AcpiExDoLogicalNumericOp ( UINT16 Opcode, - ACPI_INTEGER Integer0, - ACPI_INTEGER Integer1, + UINT64 Integer0, + UINT64 Integer1, BOOLEAN *LogicalResult) { ACPI_STATUS Status = AE_OK; @@ -690,8 +690,8 @@ AcpiExDoLogicalOp ( BOOLEAN *LogicalResult) { ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - ACPI_INTEGER Integer0; - ACPI_INTEGER Integer1; + UINT64 Integer0; + UINT64 Integer1; UINT32 Length0; UINT32 Length1; ACPI_STATUS Status = AE_OK; diff --git a/sys/contrib/dev/acpica-unix/executer/exmutex.c b/sys/contrib/dev/acpica-unix/executer/exmutex.c index e9646ca77d..1ce899289b 100644 --- a/sys/contrib/dev/acpica-unix/executer/exmutex.c +++ b/sys/contrib/dev/acpica-unix/executer/exmutex.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -513,10 +513,10 @@ AcpiExReleaseMutex ( (ObjDesc != AcpiGbl_GlobalLockMutex)) { ACPI_ERROR ((AE_INFO, - "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", - ACPI_CAST_PTR (void, WalkState->Thread->ThreadId), + "Thread %u cannot release Mutex [%4.4s] acquired by thread %u", + (UINT32) WalkState->Thread->ThreadId, AcpiUtGetNodeName (ObjDesc->Mutex.Node), - ACPI_CAST_PTR (void, OwnerThread->ThreadId))); + (UINT32) OwnerThread->ThreadId)); return_ACPI_STATUS (AE_AML_NOT_OWNER); } diff --git a/sys/contrib/dev/acpica-unix/executer/exnames.c b/sys/contrib/dev/acpica-unix/executer/exnames.c index 89fa2d4874..8fd609823b 100644 --- a/sys/contrib/dev/acpica-unix/executer/exnames.c +++ b/sys/contrib/dev/acpica-unix/executer/exnames.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -189,7 +189,7 @@ AcpiExAllocateNameString ( if (!NameString) { ACPI_ERROR ((AE_INFO, - "Could not allocate size %d", SizeNeeded)); + "Could not allocate size %u", SizeNeeded)); return_PTR (NULL); } @@ -325,7 +325,7 @@ AcpiExNameSegment ( */ Status = AE_AML_BAD_NAME; ACPI_ERROR ((AE_INFO, - "Bad character %02x in name, at %p", + "Bad character 0x%02x in name, at %p", *AmlAddress, AmlAddress)); } diff --git a/sys/contrib/dev/acpica-unix/executer/exoparg1.c b/sys/contrib/dev/acpica-unix/executer/exoparg1.c index 70085693ba..5b37a5e066 100644 --- a/sys/contrib/dev/acpica-unix/executer/exoparg1.c +++ b/sys/contrib/dev/acpica-unix/executer/exoparg1.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -183,18 +183,17 @@ AcpiExOpcode_0A_0T_1R ( /* Create a return object of type Integer */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ()); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - ReturnDesc->Integer.Value = AcpiOsGetTimer (); break; default: /* Unknown opcode */ - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; @@ -269,7 +268,7 @@ AcpiExOpcode_1A_0T_0R ( case AML_SLEEP_OP: /* Sleep (MsecTime) */ - Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); + Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value); break; @@ -287,7 +286,7 @@ AcpiExOpcode_1A_0T_0R ( default: /* Unknown opcode */ - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; @@ -333,7 +332,7 @@ AcpiExOpcode_1A_1T_0R ( default: /* Unknown opcode */ - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -369,8 +368,8 @@ AcpiExOpcode_1A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; UINT32 Temp32; UINT32 i; - ACPI_INTEGER PowerOfTen; - ACPI_INTEGER Digit; + UINT64 PowerOfTen; + UINT64 Digit; ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, @@ -478,7 +477,7 @@ AcpiExOpcode_1A_1T_1R ( /* Sum the digit into the result with the current power of 10 */ ReturnDesc->Integer.Value += - (((ACPI_INTEGER) Temp32) * PowerOfTen); + (((UINT64) Temp32) * PowerOfTen); /* Shift to next BCD digit */ @@ -507,7 +506,7 @@ AcpiExOpcode_1A_1T_1R ( * remainder from above */ ReturnDesc->Integer.Value |= - (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); + (((UINT64) Temp32) << ACPI_MUL_4 (i)); } /* Overflow if there is any data left in Digit */ @@ -515,7 +514,7 @@ AcpiExOpcode_1A_1T_1R ( if (Digit > 0) { ACPI_ERROR ((AE_INFO, - "Integer too large to convert to BCD: %8.8X%8.8X", + "Integer too large to convert to BCD: 0x%8.8X%8.8X", ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; @@ -554,7 +553,7 @@ AcpiExOpcode_1A_1T_1R ( /* The object exists in the namespace, return TRUE */ - ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + ReturnDesc->Integer.Value = ACPI_UINT64_MAX; goto Cleanup; @@ -665,7 +664,7 @@ AcpiExOpcode_1A_1T_1R ( default: /* Unknown opcode */ - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -720,7 +719,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; UINT32 Type; - ACPI_INTEGER Value; + UINT64 Value; ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, @@ -733,7 +732,7 @@ AcpiExOpcode_1A_0T_1R ( { case AML_LNOT_OP: /* LNot (Operand) */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -746,7 +745,7 @@ AcpiExOpcode_1A_0T_1R ( */ if (!Operand[0]->Integer.Value) { - ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + ReturnDesc->Integer.Value = ACPI_UINT64_MAX; } break; @@ -838,14 +837,12 @@ AcpiExOpcode_1A_0T_1R ( /* Allocate a descriptor to hold the type. */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - - ReturnDesc->Integer.Value = Type; break; @@ -917,14 +914,12 @@ AcpiExOpcode_1A_0T_1R ( * Now that we have the size of the object, create a result * object to hold the value */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject (Value); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - - ReturnDesc->Integer.Value = Value; break; @@ -1089,21 +1084,18 @@ AcpiExOpcode_1A_0T_1R ( * NOTE: index into a buffer is NOT a pointer to a * sub-buffer of the main buffer, it is only a pointer to a * single element (byte) of the buffer! + * + * Since we are returning the value of the buffer at the + * indexed location, we don't need to add an additional + * reference to the buffer itself. */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) + TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - - /* - * Since we are returning the value of the buffer at the - * indexed location, we don't need to add an additional - * reference to the buffer itself. - */ - ReturnDesc->Integer.Value = - TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]; break; @@ -1124,7 +1116,7 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Unknown Index TargetType %X in reference object %p", + "Unknown Index TargetType 0x%X in reference object %p", Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -1151,7 +1143,7 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Unknown class in reference(%p) - %2.2X", + "Unknown class in reference(%p) - 0x%2.2X", Operand[0], Operand[0]->Reference.Class)); Status = AE_TYPE; @@ -1163,7 +1155,7 @@ AcpiExOpcode_1A_0T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; diff --git a/sys/contrib/dev/acpica-unix/executer/exoparg2.c b/sys/contrib/dev/acpica-unix/executer/exoparg2.c index 7c42652cc4..b7c19ec775 100644 --- a/sys/contrib/dev/acpica-unix/executer/exoparg2.c +++ b/sys/contrib/dev/acpica-unix/executer/exoparg2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -206,33 +206,6 @@ AcpiExOpcode_2A_0T_0R ( break; } -#ifdef ACPI_GPE_NOTIFY_CHECK - /* - * GPE method wake/notify check. Here, we want to ensure that we - * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx - * GPE method during system runtime. If we do, the GPE is marked - * as "wake-only" and disabled. - * - * 1) Is the Notify() value == DeviceWake? - * 2) Is this a GPE deferred method? (An _Lxx or _Exx method) - * 3) Did the original GPE happen at system runtime? - * (versus during wake) - * - * If all three cases are true, this is a wake-only GPE that should - * be disabled at runtime. - */ - if (Value == 2) /* DeviceWake */ - { - Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ - - return_ACPI_STATUS (AE_OK) - } - } -#endif - /* * Dispatch the notify to the appropriate handler * NOTE: the request is queued for execution after this method @@ -246,7 +219,7 @@ AcpiExOpcode_2A_0T_0R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; } @@ -319,7 +292,7 @@ AcpiExOpcode_2A_2T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -383,7 +356,7 @@ AcpiExOpcode_2A_1T_1R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_INTEGER Index; + UINT64 Index; ACPI_STATUS Status = AE_OK; ACPI_SIZE Length; @@ -555,7 +528,7 @@ AcpiExOpcode_2A_1T_1R ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Index (%X%8.8X) is beyond end of object", + "Index (0x%8.8X%8.8X) is beyond end of object", ACPI_FORMAT_UINT64 (Index))); goto Cleanup; } @@ -579,7 +552,7 @@ AcpiExOpcode_2A_1T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; @@ -702,7 +675,7 @@ AcpiExOpcode_2A_0T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -716,7 +689,7 @@ StoreLogicalResult: */ if (LogicalResult) { - ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + ReturnDesc->Integer.Value = ACPI_UINT64_MAX; } Cleanup: diff --git a/sys/contrib/dev/acpica-unix/executer/exoparg3.c b/sys/contrib/dev/acpica-unix/executer/exoparg3.c index 591d6aceb1..e583c53697 100644 --- a/sys/contrib/dev/acpica-unix/executer/exoparg3.c +++ b/sys/contrib/dev/acpica-unix/executer/exoparg3.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -206,7 +206,7 @@ AcpiExOpcode_3A_0T_0R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; @@ -239,7 +239,7 @@ AcpiExOpcode_3A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; char *Buffer = NULL; ACPI_STATUS Status = AE_OK; - ACPI_INTEGER Index; + UINT64 Index; ACPI_SIZE Length; @@ -345,7 +345,7 @@ AcpiExOpcode_3A_1T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; diff --git a/sys/contrib/dev/acpica-unix/executer/exoparg6.c b/sys/contrib/dev/acpica-unix/executer/exoparg6.c index 96c16a33bd..92afffcdea 100644 --- a/sys/contrib/dev/acpica-unix/executer/exoparg6.c +++ b/sys/contrib/dev/acpica-unix/executer/exoparg6.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -305,7 +305,7 @@ AcpiExOpcode_6A_0T_1R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; - ACPI_INTEGER Index; + UINT64 Index; ACPI_OPERAND_OBJECT *ThisElement; @@ -337,15 +337,16 @@ AcpiExOpcode_6A_0T_1R ( if (Index >= Operand[0]->Package.Count) { ACPI_ERROR ((AE_INFO, - "Index (%X%8.8X) beyond package end (%X)", + "Index (0x%8.8X%8.8X) beyond package end (0x%X)", ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } /* Create an integer for the return value */ + /* Default return value is ACPI_UINT64_MAX if no match found */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -353,10 +354,6 @@ AcpiExOpcode_6A_0T_1R ( } - /* Default return value if no match found */ - - ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; - /* * Examine each element until a match is found. Both match conditions * must be satisfied for a match to occur. Within the loop, @@ -365,7 +362,7 @@ AcpiExOpcode_6A_0T_1R ( * * Upon finding a match, the loop will terminate via "break" at * the bottom. If it terminates "normally", MatchValue will be - * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no * match was found. */ for ( ; Index < Operand[0]->Package.Count; Index++) @@ -414,7 +411,7 @@ AcpiExOpcode_6A_0T_1R ( default: - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; diff --git a/sys/contrib/dev/acpica-unix/executer/exprep.c b/sys/contrib/dev/acpica-unix/executer/exprep.c index c915361e81..3355eac2e5 100644 --- a/sys/contrib/dev/acpica-unix/executer/exprep.c +++ b/sys/contrib/dev/acpica-unix/executer/exprep.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -193,12 +193,12 @@ AcpiExGenerateAccess ( FieldByteLength = FieldByteEndOffset - FieldByteOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bit length %d, Bit offset %d\n", - FieldBitLength, FieldBitOffset)); + "Bit length %u, Bit offset %u\n", + FieldBitLength, FieldBitOffset)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Byte Length %d, Byte Offset %d, End Offset %d\n", - FieldByteLength, FieldByteOffset, FieldByteEndOffset)); + "Byte Length %u, Byte Offset %u, End Offset %u\n", + FieldByteLength, FieldByteOffset, FieldByteEndOffset)); /* * Iterative search for the maximum access width that is both aligned @@ -228,18 +228,18 @@ AcpiExGenerateAccess ( Accesses = FieldEndOffset - FieldStartOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %d end is within region\n", AccessByteWidth)); + "AccessWidth %u end is within region\n", AccessByteWidth)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field Start %d, Field End %d -- requires %d accesses\n", - FieldStartOffset, FieldEndOffset, Accesses)); + "Field Start %u, Field End %u -- requires %u accesses\n", + FieldStartOffset, FieldEndOffset, Accesses)); /* Single access is optimal */ if (Accesses <= 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %d\n", + "Entire field can be accessed with one operation of size %u\n", AccessByteWidth)); return_VALUE (AccessByteWidth); } @@ -257,11 +257,11 @@ AcpiExGenerateAccess ( else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + "AccessWidth %u end is NOT within region\n", AccessByteWidth)); if (AccessByteWidth == 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field goes beyond end-of-region!\n")); + "Field goes beyond end-of-region!\n")); /* Field does not fit in the region at all */ @@ -273,8 +273,8 @@ AcpiExGenerateAccess ( * previous access */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Backing off to previous optimal access width of %d\n", - MinimumAccessWidth)); + "Backing off to previous optimal access width of %u\n", + MinimumAccessWidth)); return_VALUE (MinimumAccessWidth); } } @@ -284,7 +284,7 @@ AcpiExGenerateAccess ( * just use max access width */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Cannot access field in one operation, using width 8\n")); + "Cannot access field in one operation, using width 8\n")); return_VALUE (8); } #endif /* ACPI_UNDER_DEVELOPMENT */ @@ -362,7 +362,7 @@ AcpiExDecodeFieldAccess ( /* Invalid field access type */ ACPI_ERROR ((AE_INFO, - "Unknown field access type %X", + "Unknown field access type 0x%X", Access)); return_UINT32 (0); } @@ -444,18 +444,16 @@ AcpiExPrepCommonFieldObject ( * the same (equivalent) as the ByteAlignment. */ AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, - &ByteAlignment); + &ByteAlignment); if (!AccessBitWidth) { return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } - /* Setup width (access granularity) fields */ + /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */ ObjDesc->CommonField.AccessByteWidth = (UINT8) - ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ - - ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; + ACPI_DIV_8 (AccessBitWidth); /* * BaseByteOffset is the address of the start of the field within the @@ -468,9 +466,9 @@ AcpiExPrepCommonFieldObject ( * region or buffer. */ NearestByteAddress = - ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); + ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); ObjDesc->CommonField.BaseByteOffset = (UINT32) - ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); + ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); /* * StartFieldBitOffset is the offset of the first bit of the field within @@ -479,16 +477,6 @@ AcpiExPrepCommonFieldObject ( ObjDesc->CommonField.StartFieldBitOffset = (UINT8) (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); - /* - * Does the entire field fit within a single field access element? (datum) - * (i.e., without crossing a datum boundary) - */ - if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <= - (UINT16) AccessBitWidth) - { - ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM; - } - return_ACPI_STATUS (AE_OK); } @@ -512,8 +500,9 @@ AcpiExPrepFieldValue ( { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *SecondDesc = NULL; - UINT32 Type; ACPI_STATUS Status; + UINT32 AccessByteWidth; + UINT32 Type; ACPI_FUNCTION_TRACE (ExPrepFieldValue); @@ -532,8 +521,7 @@ AcpiExPrepFieldValue ( Type = AcpiNsGetType (Info->RegionNode); if (Type != ACPI_TYPE_REGION) { - ACPI_ERROR ((AE_INFO, - "Needed Region, found type %X (%s)", + ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", Type, AcpiUtGetTypeName (Type))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -551,8 +539,9 @@ AcpiExPrepFieldValue ( /* Initialize areas of the object that are common to all fields */ ObjDesc->CommonField.Node = Info->FieldNode; - Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags, - Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength); + Status = AcpiExPrepCommonFieldObject (ObjDesc, + Info->FieldFlags, Info->Attribute, + Info->FieldBitPosition, Info->FieldBitLength); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -567,6 +556,22 @@ AcpiExPrepFieldValue ( ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + /* Allow full data read from EC address space */ + + if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && + (ObjDesc->CommonField.BitLength > 8)) + { + AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); + + /* Maximum byte width supported is 255 */ + + if (AccessByteWidth < 256) + { + ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth; + } + } + /* An additional reference for the container */ AcpiUtAddReference (ObjDesc->Field.RegionObj); @@ -580,11 +585,11 @@ AcpiExPrepFieldValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: - ObjDesc->BankField.Value = Info->BankValue; - ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( - Info->RegionNode); - ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( - Info->RegisterNode); + ObjDesc->BankField.Value = Info->BankValue; + ObjDesc->BankField.RegionObj = + AcpiNsGetAttachedObject (Info->RegionNode); + ObjDesc->BankField.BankObj = + AcpiNsGetAttachedObject (Info->RegisterNode); /* An additional reference for the attached objects */ @@ -604,9 +609,11 @@ AcpiExPrepFieldValue ( * opcode and operands -- since the BankValue * operands must be evaluated. */ - SecondDesc = ObjDesc->Common.NextObject; - SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Data; - SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Length; + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, + Info->DataRegisterNode)->Named.Data; + SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, + Info->DataRegisterNode)->Named.Length; break; @@ -615,10 +622,10 @@ AcpiExPrepFieldValue ( /* Get the Index and Data registers */ - ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( - Info->RegisterNode); - ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( - Info->DataRegisterNode); + ObjDesc->IndexField.IndexObj = + AcpiNsGetAttachedObject (Info->RegisterNode); + ObjDesc->IndexField.DataObj = + AcpiNsGetAttachedObject (Info->DataRegisterNode); if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) { @@ -673,10 +680,10 @@ AcpiExPrepFieldValue ( * preserving the current type of that NamedObj. */ Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, - AcpiNsGetType (Info->FieldNode)); + AcpiNsGetType (Info->FieldNode)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", - Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); + Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); /* Remove local reference to the object */ diff --git a/sys/contrib/dev/acpica-unix/executer/exregion.c b/sys/contrib/dev/acpica-unix/executer/exregion.c index 958dc4e067..2a308dbeee 100644 --- a/sys/contrib/dev/acpica-unix/executer/exregion.c +++ b/sys/contrib/dev/acpica-unix/executer/exregion.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -149,7 +149,7 @@ AcpiExSystemMemorySpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { @@ -157,7 +157,8 @@ AcpiExSystemMemorySpaceHandler ( void *LogicalAddrPtr = NULL; ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; UINT32 Length; - ACPI_SIZE WindowSize; + ACPI_SIZE MapLength; + ACPI_SIZE PageBoundaryMapLength; #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED UINT32 Remainder; #endif @@ -187,7 +188,7 @@ AcpiExSystemMemorySpaceHandler ( break; default: - ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %d", + ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u", BitWidth)); return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } @@ -197,7 +198,7 @@ AcpiExSystemMemorySpaceHandler ( * Hardware does not support non-aligned data transfers, we must verify * the request. */ - (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); + (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder); if (Remainder != 0) { return_ACPI_STATUS (AE_AML_ALIGNMENT); @@ -210,8 +211,8 @@ AcpiExSystemMemorySpaceHandler ( * 2) Address beyond the current mapping? */ if ((Address < MemInfo->MappedPhysicalAddress) || - (((ACPI_INTEGER) Address + Length) > - ((ACPI_INTEGER) + (((UINT64) Address + Length) > + ((UINT64) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) { /* @@ -227,26 +228,45 @@ AcpiExSystemMemorySpaceHandler ( } /* - * Don't attempt to map memory beyond the end of the region, and - * constrain the maximum mapping size to something reasonable. + * October 2009: Attempt to map from the requested address to the + * end of the region. However, we will never map more than one + * page, nor will we cross a page boundary. */ - WindowSize = (ACPI_SIZE) + MapLength = (ACPI_SIZE) ((MemInfo->Address + MemInfo->Length) - Address); - if (WindowSize > ACPI_SYSMEM_REGION_WINDOW_SIZE) + /* + * If mapping the entire remaining portion of the region will cross + * a page boundary, just map up to the page boundary, do not cross. + * On some systems, crossing a page boundary while mapping regions + * can cause warnings if the pages have different attributes + * due to resource management. + * + * This has the added benefit of constraining a single mapping to + * one page, which is similar to the original code that used a 4k + * maximum window. + */ + PageBoundaryMapLength = + ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address; + if (PageBoundaryMapLength == 0) + { + PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; + } + + if (MapLength > PageBoundaryMapLength) { - WindowSize = ACPI_SYSMEM_REGION_WINDOW_SIZE; + MapLength = PageBoundaryMapLength; } /* Create a new mapping starting at the address given */ MemInfo->MappedLogicalAddress = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) Address, WindowSize); + (ACPI_PHYSICAL_ADDRESS) Address, MapLength); if (!MemInfo->MappedLogicalAddress) { ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X%8.8X, size %X", - ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) WindowSize)); + "Could not map memory at 0x%8.8X%8.8X, size %u", + ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength)); MemInfo->MappedLength = 0; return_ACPI_STATUS (AE_NO_MEMORY); } @@ -254,7 +274,7 @@ AcpiExSystemMemorySpaceHandler ( /* Save the physical address and mapping size */ MemInfo->MappedPhysicalAddress = Address; - MemInfo->MappedLength = WindowSize; + MemInfo->MappedLength = MapLength; } /* @@ -262,10 +282,10 @@ AcpiExSystemMemorySpaceHandler ( * access */ LogicalAddrPtr = MemInfo->MappedLogicalAddress + - ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n", BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); /* @@ -284,19 +304,19 @@ AcpiExSystemMemorySpaceHandler ( switch (BitWidth) { case 8: - *Value = (ACPI_INTEGER) ACPI_GET8 (LogicalAddrPtr); + *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr); break; case 16: - *Value = (ACPI_INTEGER) ACPI_GET16 (LogicalAddrPtr); + *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr); break; case 32: - *Value = (ACPI_INTEGER) ACPI_GET32 (LogicalAddrPtr); + *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr); break; case 64: - *Value = (ACPI_INTEGER) ACPI_GET64 (LogicalAddrPtr); + *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr); break; default: @@ -363,7 +383,7 @@ AcpiExSystemIoSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { @@ -375,7 +395,7 @@ AcpiExSystemIoSpaceHandler ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n", BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); /* Decode the function parameter */ @@ -427,7 +447,7 @@ AcpiExPciConfigSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { @@ -455,7 +475,7 @@ AcpiExPciConfigSpaceHandler ( PciRegister = (UINT16) (UINT32) Address; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, PciId->Function, PciRegister)); @@ -507,7 +527,7 @@ AcpiExCmosSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { @@ -544,7 +564,7 @@ AcpiExPciBarSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { @@ -581,15 +601,17 @@ AcpiExDataTableSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); - /* Perform the memory read or write */ - + /* + * Perform the memory read or write. The BitWidth was already + * validated. + */ switch (Function) { case ACPI_READ: @@ -599,9 +621,14 @@ AcpiExDataTableSpaceHandler ( break; case ACPI_WRITE: + + ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), + ACPI_DIV_8 (BitWidth)); + break; + default: - return_ACPI_STATUS (AE_SUPPORT); + return_ACPI_STATUS (AE_BAD_PARAMETER); } return_ACPI_STATUS (AE_OK); diff --git a/sys/contrib/dev/acpica-unix/executer/exresnte.c b/sys/contrib/dev/acpica-unix/executer/exresnte.c index 5481bc899a..494d154125 100644 --- a/sys/contrib/dev/acpica-unix/executer/exresnte.c +++ b/sys/contrib/dev/acpica-unix/executer/exresnte.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -344,7 +344,7 @@ AcpiExResolveNodeToValue ( /* No named references are allowed here */ ACPI_ERROR ((AE_INFO, - "Unsupported Reference type %X", + "Unsupported Reference type 0x%X", SourceDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -357,7 +357,7 @@ AcpiExResolveNodeToValue ( /* Default case is for unknown types */ ACPI_ERROR ((AE_INFO, - "Node %p - Unknown object type %X", + "Node %p - Unknown object type 0x%X", Node, EntryType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); diff --git a/sys/contrib/dev/acpica-unix/executer/exresolv.c b/sys/contrib/dev/acpica-unix/executer/exresolv.c index a3c8ab9b5c..27a6c5273d 100644 --- a/sys/contrib/dev/acpica-unix/executer/exresolv.c +++ b/sys/contrib/dev/acpica-unix/executer/exresolv.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -326,7 +326,7 @@ AcpiExResolveObjectToValue ( /* Invalid reference object */ ACPI_ERROR ((AE_INFO, - "Unknown TargetType %X in Index/Reference object %p", + "Unknown TargetType 0x%X in Index/Reference object %p", StackDesc->Reference.TargetType, StackDesc)); Status = AE_AML_INTERNAL; break; @@ -367,7 +367,7 @@ AcpiExResolveObjectToValue ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference type %X in %p", RefType, StackDesc)); + "Unknown Reference type 0x%X in %p", RefType, StackDesc)); Status = AE_AML_INTERNAL; break; } @@ -503,7 +503,7 @@ AcpiExResolveMultiple ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { ACPI_ERROR ((AE_INFO, - "Not a NS node %p [%s]", + "Not a namespace node %p [%s]", Node, AcpiUtGetDescriptorName (Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -605,7 +605,7 @@ AcpiExResolveMultiple ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference Class %2.2X", ObjDesc->Reference.Class)); + "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_AML_INTERNAL); } } diff --git a/sys/contrib/dev/acpica-unix/executer/exresop.c b/sys/contrib/dev/acpica-unix/executer/exresop.c index ecc63f6135..3a6be3bba9 100644 --- a/sys/contrib/dev/acpica-unix/executer/exresop.c +++ b/sys/contrib/dev/acpica-unix/executer/exresop.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -243,7 +243,7 @@ AcpiExResolveOperands ( ArgTypes = OpInfo->RuntimeArgs; if (ArgTypes == ARGI_INVALID_OPCODE) { - ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); @@ -309,7 +309,7 @@ AcpiExResolveOperands ( if (!AcpiUtValidObjectType (ObjectType)) { ACPI_ERROR ((AE_INFO, - "Bad operand object type [%X]", ObjectType)); + "Bad operand object type [0x%X]", ObjectType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -342,7 +342,7 @@ AcpiExResolveOperands ( default: ACPI_ERROR ((AE_INFO, - "Unknown Reference Class %2.2X in %p", + "Unknown Reference Class 0x%2.2X in %p", ObjDesc->Reference.Class, ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -773,7 +773,7 @@ AcpiExResolveOperands ( /* Unknown type */ ACPI_ERROR ((AE_INFO, - "Internal - Unknown ARGI (required operand) type %X", + "Internal - Unknown ARGI (required operand) type 0x%X", ThisArgType)); return_ACPI_STATUS (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica-unix/executer/exstore.c b/sys/contrib/dev/acpica-unix/executer/exstore.c index 8ec8a23cff..30414f0f7e 100644 --- a/sys/contrib/dev/acpica-unix/executer/exstore.c +++ b/sys/contrib/dev/acpica-unix/executer/exstore.c @@ -1,4 +1,3 @@ - /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support @@ -9,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -129,12 +128,6 @@ /* Local prototypes */ -static void -AcpiExDoDebugObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - UINT32 Level, - UINT32 Index); - static ACPI_STATUS AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *ValDesc, @@ -142,218 +135,6 @@ AcpiExStoreObjectToIndex ( ACPI_WALK_STATE *WalkState); -/******************************************************************************* - * - * FUNCTION: AcpiExDoDebugObject - * - * PARAMETERS: SourceDesc - Value to be stored - * Level - Indentation level (used for packages) - * Index - Current package element, zero if not pkg - * - * RETURN: None - * - * DESCRIPTION: Handles stores to the Debug Object. - * - ******************************************************************************/ - -static void -AcpiExDoDebugObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - UINT32 Level, - UINT32 Index) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); - - - /* Print line header as long as we are not in the middle of an object display */ - - if (!((Level > 0) && Index == 0)) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", - Level, " ")); - } - - /* Display index for package output only */ - - if (Index > 0) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - "(%.2u) ", Index -1)); - } - - if (!SourceDesc) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n")); - return_VOID; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s ", - AcpiUtGetObjectTypeName (SourceDesc))); - - if (!AcpiUtValidInternalObject (SourceDesc)) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - "%p, Invalid Internal Object!\n", SourceDesc)); - return_VOID; - } - } - else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", - AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), - SourceDesc)); - return_VOID; - } - else - { - return_VOID; - } - - /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ - - switch (SourceDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Output correct integer width */ - - if (AcpiGbl_IntegerByteWidth == 4) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", - (UINT32) SourceDesc->Integer.Value)); - } - else - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); - } - break; - - case ACPI_TYPE_BUFFER: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", - (UINT32) SourceDesc->Buffer.Length)); - ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, - (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); - break; - - case ACPI_TYPE_STRING: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", - SourceDesc->String.Length, SourceDesc->String.Pointer)); - break; - - case ACPI_TYPE_PACKAGE: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Contains 0x%.2X Elements]\n", - SourceDesc->Package.Count)); - - /* Output the entire contents of the package */ - - for (i = 0; i < SourceDesc->Package.Count; i++) - { - AcpiExDoDebugObject (SourceDesc->Package.Elements[i], - Level+4, i+1); - } - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ", - AcpiUtGetReferenceName (SourceDesc))); - - /* Decode the reference */ - - switch (SourceDesc->Reference.Class) - { - case ACPI_REFCLASS_INDEX: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n", - SourceDesc->Reference.Value)); - break; - - case ACPI_REFCLASS_TABLE: - - /* Case for DdbHandle */ - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n", - SourceDesc->Reference.Value)); - return; - - default: - break; - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, " ")); - - /* Check for valid node first, then valid object */ - - if (SourceDesc->Reference.Node) - { - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != - ACPI_DESC_TYPE_NAMED) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, - " %p - Not a valid namespace node\n", - SourceDesc->Reference.Node)); - } - else - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Node %p [%4.4s] ", - SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii)); - - switch ((SourceDesc->Reference.Node)->Type) - { - /* These types have no attached object */ - - case ACPI_TYPE_DEVICE: - AcpiOsPrintf ("Device\n"); - break; - - case ACPI_TYPE_THERMAL: - AcpiOsPrintf ("Thermal Zone\n"); - break; - - default: - AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, - Level+4, 0); - break; - } - } - } - else if (SourceDesc->Reference.Object) - { - if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == - ACPI_DESC_TYPE_NAMED) - { - AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) - SourceDesc->Reference.Object)->Object, - Level+4, 0); - } - else - { - AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); - } - } - break; - - default: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", - SourceDesc)); - break; - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); - return_VOID; -} - - /******************************************************************************* * * FUNCTION: AcpiExStore @@ -487,13 +268,13 @@ AcpiExStore ( "**** Write to Debug Object: Object %p %s ****:\n\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); - AcpiExDoDebugObject (SourceDesc, 0, 0); + ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); break; default: - ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", RefDesc->Reference.Class)); ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); diff --git a/sys/contrib/dev/acpica-unix/executer/exstoren.c b/sys/contrib/dev/acpica-unix/executer/exstoren.c index 0810560d39..cee5bc64ce 100644 --- a/sys/contrib/dev/acpica-unix/executer/exstoren.c +++ b/sys/contrib/dev/acpica-unix/executer/exstoren.c @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/executer/exstorob.c b/sys/contrib/dev/acpica-unix/executer/exstorob.c index a1ad8d0aed..e9adf5f7ac 100644 --- a/sys/contrib/dev/acpica-unix/executer/exstorob.c +++ b/sys/contrib/dev/acpica-unix/executer/exstorob.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -150,6 +150,13 @@ AcpiExStoreBufferToBuffer ( ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + /* We know that SourceDesc is a buffer by now */ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); @@ -248,6 +255,13 @@ AcpiExStoreStringToString ( ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + /* We know that SourceDesc is a string by now */ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); diff --git a/sys/contrib/dev/acpica-unix/executer/exsystem.c b/sys/contrib/dev/acpica-unix/executer/exsystem.c index 19674606a6..ab36f756e5 100644 --- a/sys/contrib/dev/acpica-unix/executer/exsystem.c +++ b/sys/contrib/dev/acpica-unix/executer/exsystem.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -265,7 +265,7 @@ AcpiExSystemDoStall ( * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_ERROR ((AE_INFO, "Time parameter is too large (%d)", + ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)", HowLong)); Status = AE_AML_OPERAND_VALUE; } @@ -280,20 +280,20 @@ AcpiExSystemDoStall ( /******************************************************************************* * - * FUNCTION: AcpiExSystemDoSuspend + * FUNCTION: AcpiExSystemDoSleep * - * PARAMETERS: HowLong - The amount of time to suspend, + * PARAMETERS: HowLong - The amount of time to sleep, * in milliseconds * * RETURN: None * - * DESCRIPTION: Suspend running thread for specified amount of time. + * DESCRIPTION: Sleep the running thread for specified amount of time. * ******************************************************************************/ ACPI_STATUS -AcpiExSystemDoSuspend ( - ACPI_INTEGER HowLong) +AcpiExSystemDoSleep ( + UINT64 HowLong) { ACPI_FUNCTION_ENTRY (); @@ -302,6 +302,15 @@ AcpiExSystemDoSuspend ( AcpiExRelinquishInterpreter (); + /* + * For compatibility with other ACPI implementations and to prevent + * accidental deep sleeps, limit the sleep time to something reasonable. + */ + if (HowLong > ACPI_MAX_SLEEP) + { + HowLong = ACPI_MAX_SLEEP; + } + AcpiOsSleep (HowLong); /* And now we must get the interpreter again */ diff --git a/sys/contrib/dev/acpica-unix/executer/exutils.c b/sys/contrib/dev/acpica-unix/executer/exutils.c index 45b35a0c25..5a0a9a59db 100644 --- a/sys/contrib/dev/acpica-unix/executer/exutils.c +++ b/sys/contrib/dev/acpica-unix/executer/exutils.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -144,7 +144,7 @@ static UINT32 AcpiExDigitsNeeded ( - ACPI_INTEGER Value, + UINT64 Value, UINT32 Base); @@ -334,7 +334,7 @@ AcpiExTruncateFor32bitTable ( * We are running a method that exists in a 32-bit ACPI table. * Truncate the value to 32 bits by zeroing out the upper 32-bit field */ - ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; + ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX; } } @@ -446,17 +446,17 @@ AcpiExReleaseGlobalLock ( static UINT32 AcpiExDigitsNeeded ( - ACPI_INTEGER Value, + UINT64 Value, UINT32 Base) { UINT32 NumDigits; - ACPI_INTEGER CurrentValue; + UINT64 CurrentValue; ACPI_FUNCTION_TRACE (ExDigitsNeeded); - /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + /* UINT64 is unsigned, so we don't worry about a '-' prefix */ if (Value == 0) { @@ -482,59 +482,76 @@ AcpiExDigitsNeeded ( * * FUNCTION: AcpiExEisaIdToString * - * PARAMETERS: NumericId - EISA ID to be converted + * PARAMETERS: CompressedId - EISAID to be converted * OutString - Where to put the converted string (8 bytes) * * RETURN: None * - * DESCRIPTION: Convert a numeric EISA ID to string representation + * DESCRIPTION: Convert a numeric EISAID to string representation. Return + * buffer must be large enough to hold the string. The string + * returned is always exactly of length ACPI_EISAID_STRING_SIZE + * (includes null terminator). The EISAID is always 32 bits. * ******************************************************************************/ void AcpiExEisaIdToString ( - UINT32 NumericId, - char *OutString) + char *OutString, + UINT64 CompressedId) { - UINT32 EisaId; + UINT32 SwappedId; ACPI_FUNCTION_ENTRY (); + /* The EISAID should be a 32-bit integer */ + + if (CompressedId > ACPI_UINT32_MAX) + { + ACPI_WARNING ((AE_INFO, + "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + ACPI_FORMAT_UINT64 (CompressedId))); + } + /* Swap ID to big-endian to get contiguous bits */ - EisaId = AcpiUtDwordByteSwap (NumericId); + SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); + + /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ - OutString[0] = (char) ('@' + (((unsigned long) EisaId >> 26) & 0x1f)); - OutString[1] = (char) ('@' + ((EisaId >> 21) & 0x1f)); - OutString[2] = (char) ('@' + ((EisaId >> 16) & 0x1f)); - OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12); - OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8); - OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4); - OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0); + OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); + OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); + OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); + OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12); + OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8); + OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4); + OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0); OutString[7] = 0; } /******************************************************************************* * - * FUNCTION: AcpiExUnsignedIntegerToString + * FUNCTION: AcpiExIntegerToString * - * PARAMETERS: Value - Value to be converted - * OutString - Where to put the converted string (8 bytes) + * PARAMETERS: OutString - Where to put the converted string. At least + * 21 bytes are needed to hold the largest + * possible 64-bit integer. + * Value - Value to be converted * * RETURN: None, string * - * DESCRIPTION: Convert a number to string representation. Assumes string - * buffer is large enough to hold the string. + * DESCRIPTION: Convert a 64-bit integer to decimal string representation. + * Assumes string buffer is large enough to hold the string. The + * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). * ******************************************************************************/ void -AcpiExUnsignedIntegerToString ( - ACPI_INTEGER Value, - char *OutString) +AcpiExIntegerToString ( + char *OutString, + UINT64 Value) { UINT32 Count; UINT32 DigitsNeeded; diff --git a/sys/contrib/dev/acpica-unix/generate/lint/options.lnt b/sys/contrib/dev/acpica-unix/generate/lint/options.lnt index ca4f90beec..1ede674cc8 100644 --- a/sys/contrib/dev/acpica-unix/generate/lint/options.lnt +++ b/sys/contrib/dev/acpica-unix/generate/lint/options.lnt @@ -33,6 +33,8 @@ -emacro( (413), ACPI_PTR_DIFF ) // use of NULL pointer creates a stir -emacro( (413), ACPI_FADT_OFFSET ) // use of NULL pointer creates a stir -emacro( (413), ASL_RESDESC_OFFSET ) // use of NULL pointer creates a stir +-emacro( (662), ACPI_ADD_PTR ) // allow pointer overrun for dynamic structs +-emacro( (797), ACPI_ADD_PTR ) // allow pointer overrun for dynamic structs -emacro( 826, ACPI_NEXT_RESOURCE) // Pointer cast -emacro( 826, ACPI_MOVE_UNALIGNED16_TO_16) // Pointer cast @@ -76,4 +78,6 @@ -e834 // - followed by + is "confusing" NOT. -e820 // Allow Boolean test of a parenthesized assignment -e778 // Allow constant expressions to evaluate to zero --e831 \ No newline at end of file +-e662 // Allow "pointer overrun" for dynamic structures +-e831 +-e784 // Allow "Nul character truncated from string" for lookup tables diff --git a/sys/contrib/dev/acpica-unix/hardware/hwacpi.c b/sys/contrib/dev/acpica-unix/hardware/hwacpi.c index 6b6d90ee02..b4ceb390ef 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwacpi.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwacpi.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/hardware/hwgpe.c b/sys/contrib/dev/acpica-unix/hardware/hwgpe.c index b7bb0b47f5..b12bab6bca 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwgpe.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwgpe.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -132,23 +132,54 @@ AcpiHwEnableWakeupGpeBlock ( /****************************************************************************** * - * FUNCTION: AcpiHwLowDisableGpe + * FUNCTION: AcpiHwGetGpeRegisterBit + * + * PARAMETERS: GpeEventInfo - Info block for the GPE + * GpeRegisterInfo - Info block for the GPE register + * + * RETURN: Register mask with a one in the GPE bit position + * + * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the + * correct position for the input GPE. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetGpeRegisterBit ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo) +{ + + return ((UINT32) 1 << + (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwLowSetGpe * * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled + * Action - Enable or disable * * RETURN: Status * - * DESCRIPTION: Disable a single GPE in the enable register. + * DESCRIPTION: Enable or disable a single GPE in the parent enable register. * ******************************************************************************/ ACPI_STATUS -AcpiHwLowDisableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) +AcpiHwLowSetGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 Action) { ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; UINT32 EnableMask; + UINT32 RegisterBit; + + + ACPI_FUNCTION_ENTRY (); /* Get the info block for the entire GPE register */ @@ -161,63 +192,44 @@ AcpiHwLowDisableGpe ( /* Get current value of the enable register that contains this GPE */ - Status = AcpiRead (&EnableMask, &GpeRegisterInfo->EnableAddress); + Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); } - /* Clear just the bit that corresponds to this GPE */ - - ACPI_CLEAR_BIT (EnableMask, ((UINT32) 1 << - (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber))); - - - /* Write the updated enable mask */ - - Status = AcpiWrite (EnableMask, &GpeRegisterInfo->EnableAddress); - return (Status); -} + /* Set or clear just the bit that corresponds to this GPE */ + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); + switch (Action) + { + case ACPI_GPE_CONDITIONAL_ENABLE: -/****************************************************************************** - * - * FUNCTION: AcpiHwWriteGpeEnableReg - * - * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled - * - * RETURN: Status - * - * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must - * already be cleared or set in the parent register - * EnableForRun mask. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiHwWriteGpeEnableReg ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - ACPI_STATUS Status; + /* Only enable if the EnableForRun bit is set */ + if (!(RegisterBit & GpeRegisterInfo->EnableForRun)) + { + return (AE_BAD_PARAMETER); + } - ACPI_FUNCTION_ENTRY (); + /*lint -fallthrough */ + case ACPI_GPE_ENABLE: + ACPI_SET_BIT (EnableMask, RegisterBit); + break; - /* Get the info block for the entire GPE register */ + case ACPI_GPE_DISABLE: + ACPI_CLEAR_BIT (EnableMask, RegisterBit); + break; - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return (AE_NOT_EXIST); + default: + ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action)); + return (AE_BAD_PARAMETER); } - /* Write the entire GPE (runtime) enable register */ - - Status = AcpiWrite (GpeRegisterInfo->EnableForRun, - &GpeRegisterInfo->EnableAddress); + /* Write the updated enable mask */ + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); return (Status); } @@ -238,22 +250,29 @@ ACPI_STATUS AcpiHwClearGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo) { + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; - UINT8 RegisterBit; + UINT32 RegisterBit; ACPI_FUNCTION_ENTRY (); + /* Get the info block for the entire GPE register */ - RegisterBit = (UINT8) (1 << - (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } /* * Write a one to the appropriate bit in the status register to * clear this GPE. */ - Status = AcpiWrite (RegisterBit, - &GpeEventInfo->RegisterInfo->StatusAddress); + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); + + Status = AcpiHwWrite (RegisterBit, + &GpeRegisterInfo->StatusAddress); return (Status); } @@ -278,10 +297,10 @@ AcpiHwGetGpeStatus ( ACPI_EVENT_STATUS *EventStatus) { UINT32 InByte; - UINT8 RegisterBit; + UINT32 RegisterBit; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - ACPI_STATUS Status; ACPI_EVENT_STATUS LocalEventStatus = 0; + ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); @@ -298,8 +317,7 @@ AcpiHwGetGpeStatus ( /* Get the register bitmask for this GPE */ - RegisterBit = (UINT8) (1 << - (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); /* GPE currently enabled? (enabled for runtime?) */ @@ -317,10 +335,10 @@ AcpiHwGetGpeStatus ( /* GPE currently active (status bit == 1)? */ - Status = AcpiRead (&InByte, &GpeRegisterInfo->StatusAddress); + Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) { - goto UnlockAndExit; + return (Status); } if (RegisterBit & InByte) @@ -331,10 +349,7 @@ AcpiHwGetGpeStatus ( /* Set return value */ (*EventStatus) = LocalEventStatus; - - -UnlockAndExit: - return (Status); + return (AE_OK); } @@ -367,7 +382,7 @@ AcpiHwDisableGpeBlock ( { /* Disable all GPEs in this register */ - Status = AcpiWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); + Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); @@ -407,7 +422,7 @@ AcpiHwClearGpeBlock ( { /* Clear status on all GPEs in this register */ - Status = AcpiWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); + Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); if (ACPI_FAILURE (Status)) { return (Status); @@ -455,7 +470,7 @@ AcpiHwEnableRuntimeGpeBlock ( /* Enable all "runtime" GPEs in this register */ - Status = AcpiWrite (GpeBlock->RegisterInfo[i].EnableForRun, + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { @@ -502,7 +517,7 @@ AcpiHwEnableWakeupGpeBlock ( /* Enable all "wake" GPEs in this register */ - Status = AcpiWrite (GpeBlock->RegisterInfo[i].EnableForWake, + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica-unix/hardware/hwpci.c b/sys/contrib/dev/acpica-unix/hardware/hwpci.c new file mode 100644 index 0000000000..d733b1164c --- /dev/null +++ b/sys/contrib/dev/acpica-unix/hardware/hwpci.c @@ -0,0 +1,531 @@ +/******************************************************************************* + * + * Module Name: hwpci - Obtain PCI bus, device, and function numbers + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWPCI_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("hwpci") + + +/* PCI configuration space values */ + +#define PCI_CFG_HEADER_TYPE_REG 0x0E +#define PCI_CFG_PRIMARY_BUS_NUMBER_REG 0x18 +#define PCI_CFG_SECONDARY_BUS_NUMBER_REG 0x19 + +/* PCI header values */ + +#define PCI_HEADER_TYPE_MASK 0x7F +#define PCI_TYPE_BRIDGE 0x01 +#define PCI_TYPE_CARDBUS_BRIDGE 0x02 + +typedef struct acpi_pci_device +{ + ACPI_HANDLE Device; + struct acpi_pci_device *Next; + +} ACPI_PCI_DEVICE; + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwBuildPciList ( + ACPI_HANDLE RootPciDevice, + ACPI_HANDLE PciRegion, + ACPI_PCI_DEVICE **ReturnListHead); + +static ACPI_STATUS +AcpiHwProcessPciList ( + ACPI_PCI_ID *PciId, + ACPI_PCI_DEVICE *ListHead); + +static void +AcpiHwDeletePciList ( + ACPI_PCI_DEVICE *ListHead); + +static ACPI_STATUS +AcpiHwGetPciDeviceInfo ( + ACPI_PCI_ID *PciId, + ACPI_HANDLE PciDevice, + UINT16 *BusNumber, + BOOLEAN *IsBridge); + + +/******************************************************************************* + * + * FUNCTION: AcpiHwDerivePciId + * + * PARAMETERS: PciId - Initial values for the PCI ID. May be + * modified by this function. + * RootPciDevice - A handle to a PCI device object. This + * object must be a PCI Root Bridge having a + * _HID value of either PNP0A03 or PNP0A08 + * PciRegion - A handle to a PCI configuration space + * Operation Region being initialized + * + * RETURN: Status + * + * DESCRIPTION: This function derives a full PCI ID for a PCI device, + * consisting of a Segment number, Bus number, Device number, + * and function code. + * + * The PCI hardware dynamically configures PCI bus numbers + * depending on the bus topology discovered during system + * initialization. This function is invoked during configuration + * of a PCI_Config Operation Region in order to (possibly) update + * the Bus/Device/Function numbers in the PciId with the actual + * values as determined by the hardware and operating system + * configuration. + * + * The PciId parameter is initially populated during the Operation + * Region initialization. This function is then called, and is + * will make any necessary modifications to the Bus, Device, or + * Function number PCI ID subfields as appropriate for the + * current hardware and OS configuration. + * + * NOTE: Created 08/2010. Replaces the previous OSL AcpiOsDerivePciId + * interface since this feature is OS-independent. This module + * specifically avoids any use of recursion by building a local + * temporary device list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDerivePciId ( + ACPI_PCI_ID *PciId, + ACPI_HANDLE RootPciDevice, + ACPI_HANDLE PciRegion) +{ + ACPI_STATUS Status; + ACPI_PCI_DEVICE *ListHead = NULL; + + + ACPI_FUNCTION_TRACE (HwDerivePciId); + + + if (!PciId) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Build a list of PCI devices, from PciRegion up to RootPciDevice */ + + Status = AcpiHwBuildPciList (RootPciDevice, PciRegion, &ListHead); + if (ACPI_SUCCESS (Status)) + { + /* Walk the list, updating the PCI device/function/bus numbers */ + + Status = AcpiHwProcessPciList (PciId, ListHead); + } + + /* Always delete the list */ + + AcpiHwDeletePciList (ListHead); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwBuildPciList + * + * PARAMETERS: RootPciDevice - A handle to a PCI device object. This + * object is guaranteed to be a PCI Root + * Bridge having a _HID value of either + * PNP0A03 or PNP0A08 + * PciRegion - A handle to the PCI configuration space + * Operation Region + * ReturnListHead - Where the PCI device list is returned + * + * RETURN: Status + * + * DESCRIPTION: Builds a list of devices from the input PCI region up to the + * Root PCI device for this namespace subtree. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwBuildPciList ( + ACPI_HANDLE RootPciDevice, + ACPI_HANDLE PciRegion, + ACPI_PCI_DEVICE **ReturnListHead) +{ + ACPI_HANDLE CurrentDevice; + ACPI_HANDLE ParentDevice; + ACPI_STATUS Status; + ACPI_PCI_DEVICE *ListElement; + ACPI_PCI_DEVICE *ListHead = NULL; + + + /* + * Ascend namespace branch until the RootPciDevice is reached, building + * a list of device nodes. Loop will exit when either the PCI device is + * found, or the root of the namespace is reached. + */ + CurrentDevice = PciRegion; + while (1) + { + Status = AcpiGetParent (CurrentDevice, &ParentDevice); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */ + + if (ParentDevice == RootPciDevice) + { + *ReturnListHead = ListHead; + return (AE_OK); + } + + ListElement = ACPI_ALLOCATE (sizeof (ACPI_PCI_DEVICE)); + if (!ListElement) + { + return (AE_NO_MEMORY); + } + + /* Put new element at the head of the list */ + + ListElement->Next = ListHead; + ListElement->Device = ParentDevice; + ListHead = ListElement; + + CurrentDevice = ParentDevice; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwProcessPciList + * + * PARAMETERS: PciId - Initial values for the PCI ID. May be + * modified by this function. + * ListHead - Device list created by + * AcpiHwBuildPciList + * + * RETURN: Status + * + * DESCRIPTION: Walk downward through the PCI device list, getting the device + * info for each, via the PCI configuration space and updating + * the PCI ID as necessary. Deletes the list during traversal. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwProcessPciList ( + ACPI_PCI_ID *PciId, + ACPI_PCI_DEVICE *ListHead) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PCI_DEVICE *Info; + UINT16 BusNumber; + BOOLEAN IsBridge = TRUE; + + + ACPI_FUNCTION_NAME (HwProcessPciList); + + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Input PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X\n", + PciId->Segment, PciId->Bus, PciId->Device, PciId->Function)); + + BusNumber = PciId->Bus; + + /* + * Descend down the namespace tree, collecting PCI device, function, + * and bus numbers. BusNumber is only important for PCI bridges. + * Algorithm: As we descend the tree, use the last valid PCI device, + * function, and bus numbers that are discovered, and assign them + * to the PCI ID for the target device. + */ + Info = ListHead; + while (Info) + { + Status = AcpiHwGetPciDeviceInfo (PciId, Info->Device, + &BusNumber, &IsBridge); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Info = Info->Next; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Output PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X " + "Status %X BusNumber %X IsBridge %X\n", + PciId->Segment, PciId->Bus, PciId->Device, PciId->Function, + Status, BusNumber, IsBridge)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwDeletePciList + * + * PARAMETERS: ListHead - Device list created by + * AcpiHwBuildPciList + * + * RETURN: None + * + * DESCRIPTION: Free the entire PCI list. + * + ******************************************************************************/ + +static void +AcpiHwDeletePciList ( + ACPI_PCI_DEVICE *ListHead) +{ + ACPI_PCI_DEVICE *Next; + ACPI_PCI_DEVICE *Previous; + + + Next = ListHead; + while (Next) + { + Previous = Next; + Next = Previous->Next; + ACPI_FREE (Previous); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetPciDeviceInfo + * + * PARAMETERS: PciId - Initial values for the PCI ID. May be + * modified by this function. + * PciDevice - Handle for the PCI device object + * BusNumber - Where a PCI bridge bus number is returned + * IsBridge - Return value, indicates if this PCI + * device is a PCI bridge + * + * RETURN: Status + * + * DESCRIPTION: Get the device info for a single PCI device object. Get the + * _ADR (contains PCI device and function numbers), and for PCI + * bridge devices, get the bus number from PCI configuration + * space. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwGetPciDeviceInfo ( + ACPI_PCI_ID *PciId, + ACPI_HANDLE PciDevice, + UINT16 *BusNumber, + BOOLEAN *IsBridge) +{ + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + UINT64 ReturnValue; + UINT64 PciValue; + + + /* We only care about objects of type Device */ + + Status = AcpiGetType (PciDevice, &ObjectType); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (ObjectType != ACPI_TYPE_DEVICE) + { + return (AE_OK); + } + + /* We need an _ADR. Ignore device if not present */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, + PciDevice, &ReturnValue); + if (ACPI_FAILURE (Status)) + { + return (AE_OK); + } + + /* + * From _ADR, get the PCI Device and Function and + * update the PCI ID. + */ + PciId->Device = ACPI_HIWORD (ACPI_LODWORD (ReturnValue)); + PciId->Function = ACPI_LOWORD (ACPI_LODWORD (ReturnValue)); + + /* + * If the previous device was a bridge, use the previous + * device bus number + */ + if (*IsBridge) + { + PciId->Bus = *BusNumber; + } + + /* + * Get the bus numbers from PCI Config space: + * + * First, get the PCI HeaderType + */ + *IsBridge = FALSE; + Status = AcpiOsReadPciConfiguration (PciId, + PCI_CFG_HEADER_TYPE_REG, &PciValue, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* We only care about bridges (1=PciBridge, 2=CardBusBridge) */ + + PciValue &= PCI_HEADER_TYPE_MASK; + + if ((PciValue != PCI_TYPE_BRIDGE) && + (PciValue != PCI_TYPE_CARDBUS_BRIDGE)) + { + return (AE_OK); + } + + /* Bridge: Get the Primary BusNumber */ + + Status = AcpiOsReadPciConfiguration (PciId, + PCI_CFG_PRIMARY_BUS_NUMBER_REG, &PciValue, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *IsBridge = TRUE; + PciId->Bus = (UINT16) PciValue; + + /* Bridge: Get the Secondary BusNumber */ + + Status = AcpiOsReadPciConfiguration (PciId, + PCI_CFG_SECONDARY_BUS_NUMBER_REG, &PciValue, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *BusNumber = (UINT16) PciValue; + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/hardware/hwregs.c b/sys/contrib/dev/acpica-unix/hardware/hwregs.c index cfb83f22e6..2e43a4af90 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwregs.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwregs.c @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -140,6 +140,209 @@ AcpiHwWriteMultiple ( ACPI_GENERIC_ADDRESS *RegisterB); +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateRegister + * + * PARAMETERS: Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * Address - Pointer to where the gas->address + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS + * pointer, Address, SpaceId, BitWidth, and BitOffset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address) +{ + + /* Must have a valid pointer to a GAS structure */ + + if (!Reg) + { + return (AE_BAD_PARAMETER); + } + + /* + * Copy the target address. This handles possible alignment issues. + * Address must not be null. A null address also indicates an optional + * ACPI register that is not supported, so no error message. + */ + ACPI_MOVE_64_TO_64 (Address, &Reg->Address); + if (!(*Address)) + { + return (AE_BAD_ADDRESS); + } + + /* Validate the SpaceID */ + + if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported address space: 0x%X", Reg->SpaceId)); + return (AE_SUPPORT); + } + + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported register bit width: 0x%X", Reg->BitWidth)); + return (AE_SUPPORT); + } + + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) + { + ACPI_WARNING ((AE_INFO, + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max + * version of AcpiRead, used internally since the overhead of + * 64-bit values is not needed. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, or 32. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwRead); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize entire 32-bit return value to zero */ + + *Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max + * version of AcpiWrite, used internally since the overhead of + * 64-bit values is not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwWrite); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiHwClearAcpiStatus @@ -209,7 +412,7 @@ AcpiHwGetBitRegisterInfo ( if (RegisterId > ACPI_BITREG_MAX) { - ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: %X", RegisterId)); + ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: 0x%X", RegisterId)); return (NULL); } @@ -245,7 +448,7 @@ AcpiHwWritePm1Control ( ACPI_FUNCTION_TRACE (HwWritePm1Control); - Status = AcpiWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); + Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -253,7 +456,7 @@ AcpiHwWritePm1Control ( if (AcpiGbl_FADT.XPm1bControlBlock.Address) { - Status = AcpiWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); + Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); } return_ACPI_STATUS (Status); } @@ -319,13 +522,13 @@ AcpiHwRegisterRead ( case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); break; @@ -336,7 +539,7 @@ AcpiHwRegisterRead ( default: - ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X", RegisterId)); Status = AE_BAD_PARAMETER; break; @@ -450,7 +653,7 @@ AcpiHwRegisterWrite ( * For control registers, all reserved bits must be preserved, * as per the ACPI spec. */ - Status = AcpiRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); if (ACPI_FAILURE (Status)) { goto Exit; @@ -460,13 +663,13 @@ AcpiHwRegisterWrite ( ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue); - Status = AcpiWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); break; @@ -479,7 +682,7 @@ AcpiHwRegisterWrite ( default: - ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X", RegisterId)); Status = AE_BAD_PARAMETER; break; @@ -517,7 +720,7 @@ AcpiHwReadMultiple ( /* The first register is always required */ - Status = AcpiRead (&ValueA, RegisterA); + Status = AcpiHwRead (&ValueA, RegisterA); if (ACPI_FAILURE (Status)) { return (Status); @@ -527,7 +730,7 @@ AcpiHwReadMultiple ( if (RegisterB->Address) { - Status = AcpiRead (&ValueB, RegisterB); + Status = AcpiHwRead (&ValueB, RegisterB); if (ACPI_FAILURE (Status)) { return (Status); @@ -574,7 +777,7 @@ AcpiHwWriteMultiple ( /* The first register is always required */ - Status = AcpiWrite (Value, RegisterA); + Status = AcpiHwWrite (Value, RegisterA); if (ACPI_FAILURE (Status)) { return (Status); @@ -594,7 +797,7 @@ AcpiHwWriteMultiple ( */ if (RegisterB->Address) { - Status = AcpiWrite (Value, RegisterB); + Status = AcpiHwWrite (Value, RegisterB); } return (Status); diff --git a/sys/contrib/dev/acpica-unix/hardware/hwsleep.c b/sys/contrib/dev/acpica-unix/hardware/hwsleep.c index 32a7934636..fe796ec273 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwsleep.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwsleep.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -319,7 +319,7 @@ AcpiEnterSleepState ( if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) { - ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=%X B=%X", + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } @@ -345,10 +345,13 @@ AcpiEnterSleepState ( if (SleepState != ACPI_STATE_S5) { - /* Disable BM arbitration */ - + /* + * Disable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); - if (ACPI_FAILURE (Status)) + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) { return_ACPI_STATUS (Status); } @@ -393,7 +396,7 @@ AcpiEnterSleepState ( return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Entering sleep state [S%d]\n", SleepState)); + "Entering sleep state [S%u]\n", SleepState)); /* Clear the SLP_EN and SLP_TYP fields */ @@ -683,10 +686,13 @@ AcpiLeaveSleepState ( AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, ACPI_CLEAR_STATUS); - /* Enable BM arbitration */ - + /* + * Enable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); - if (ACPI_FAILURE (Status)) + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) { return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica-unix/hardware/hwtimer.c b/sys/contrib/dev/acpica-unix/hardware/hwtimer.c index ad9934cdaa..79ddb8e540 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwtimer.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwtimer.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -187,7 +187,7 @@ AcpiGetTimer ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); return_ACPI_STATUS (Status); } @@ -232,7 +232,7 @@ AcpiGetTimerDuration ( { ACPI_STATUS Status; UINT32 DeltaTicks; - ACPI_INTEGER Quotient; + UINT64 Quotient; ACPI_FUNCTION_TRACE (AcpiGetTimerDuration); diff --git a/sys/contrib/dev/acpica-unix/hardware/hwvalid.c b/sys/contrib/dev/acpica-unix/hardware/hwvalid.c index 650b695b2c..92b9a4e71e 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwvalid.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwvalid.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -237,7 +237,7 @@ AcpiHwValidateIoRequest ( if (LastAddress > ACPI_UINT16_MAX) { ACPI_ERROR ((AE_INFO, - "Illegal I/O port address/length above 64K: 0x%p/%X", + "Illegal I/O port address/length above 64K: %p/0x%X", ACPI_CAST_PTR (void, Address), ByteWidth)); return_ACPI_STATUS (AE_LIMIT); } @@ -316,6 +316,13 @@ AcpiHwReadPort ( UINT32 i; + /* Truncate address to 16 bits if requested */ + + if (AcpiGbl_TruncateIoAddresses) + { + Address &= ACPI_UINT16_MAX; + } + /* Validate the entire request and perform the I/O */ Status = AcpiHwValidateIoRequest (Address, Width); @@ -383,6 +390,13 @@ AcpiHwWritePort ( UINT32 i; + /* Truncate address to 16 bits if requested */ + + if (AcpiGbl_TruncateIoAddresses) + { + Address &= ACPI_UINT16_MAX; + } + /* Validate the entire request and perform the I/O */ Status = AcpiHwValidateIoRequest (Address, Width); diff --git a/sys/contrib/dev/acpica-unix/hardware/hwxface.c b/sys/contrib/dev/acpica-unix/hardware/hwxface.c index 63641d3893..e7bcbe0ae9 100644 --- a/sys/contrib/dev/acpica-unix/hardware/hwxface.c +++ b/sys/contrib/dev/acpica-unix/hardware/hwxface.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -157,9 +157,23 @@ AcpiReset ( return_ACPI_STATUS (AE_NOT_EXIST); } - /* Write the reset value to the reset register */ + if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + /* + * For I/O space, write directly to the OSL. This bypasses the port + * validation mechanism, which may block a valid write to the reset + * register. + */ + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, + AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + } + else + { + /* Write the reset value to the reset register */ + + Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg); + } - Status = AcpiWrite (AcpiGbl_FADT.ResetValue, ResetReg); return_ACPI_STATUS (Status); } @@ -177,13 +191,20 @@ ACPI_EXPORT_SYMBOL (AcpiReset) * * DESCRIPTION: Read from either memory or IO space. * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, 32, or 64. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * ******************************************************************************/ ACPI_STATUS AcpiRead ( - UINT32 *Value, + UINT64 *ReturnValue, ACPI_GENERIC_ADDRESS *Reg) { + UINT32 Value; UINT32 Width; UINT64 Address; ACPI_STATUS Status; @@ -192,63 +213,85 @@ AcpiRead ( ACPI_FUNCTION_NAME (AcpiRead); - /* - * Must have a valid pointer to a GAS structure, and a non-zero address - * within. - */ - if (!Reg) + if (!ReturnValue) { return (AE_BAD_PARAMETER); } - /* Get a local copy of the address. Handles possible alignment issues */ + /* Validate contents of the GAS register. Allow 64-bit transfers */ - ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!Address) + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) { - return (AE_BAD_ADDRESS); + return (Status); } - /* Supported widths are 8/16/32 */ - Width = Reg->BitWidth; - if ((Width != 8) && (Width != 16) && (Width != 32)) + if (Width == 64) { - return (AE_SUPPORT); + Width = 32; /* Break into two 32-bit transfers */ } - /* Initialize entire 32-bit return value to zero */ + /* Initialize entire 64-bit return value to zero */ - *Value = 0; + *ReturnValue = 0; + Value = 0; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - switch (Reg->SpaceId) + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - - Status = AcpiOsReadMemory ( - (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); - break; - - - case ACPI_ADR_SPACE_SYSTEM_IO: - - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, Value, Width); - break; + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; - default: - ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->SpaceId)); - return (AE_BAD_PARAMETER); + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } } ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Width, ACPI_FORMAT_UINT64 (Address), + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -261,7 +304,7 @@ ACPI_EXPORT_SYMBOL (AcpiRead) * * FUNCTION: AcpiWrite * - * PARAMETERS: Value - To be written + * PARAMETERS: Value - Value to be written * Reg - GAS register structure * * RETURN: Status @@ -272,7 +315,7 @@ ACPI_EXPORT_SYMBOL (AcpiRead) ACPI_STATUS AcpiWrite ( - UINT32 Value, + UINT64 Value, ACPI_GENERIC_ADDRESS *Reg) { UINT32 Width; @@ -283,60 +326,67 @@ AcpiWrite ( ACPI_FUNCTION_NAME (AcpiWrite); - /* - * Must have a valid pointer to a GAS structure, and a non-zero address - * within. - */ - if (!Reg) - { - return (AE_BAD_PARAMETER); - } - - /* Get a local copy of the address. Handles possible alignment issues */ + /* Validate contents of the GAS register. Allow 64-bit transfers */ - ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!Address) + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) { - return (AE_BAD_ADDRESS); + return (Status); } - /* Supported widths are 8/16/32 */ - Width = Reg->BitWidth; - if ((Width != 8) && (Width != 16) && (Width != 32)) + if (Width == 64) { - return (AE_SUPPORT); + Width = 32; /* Break into two 32-bit transfers */ } /* - * Two address spaces supported: Memory or IO. - * PCI_Config is not supported here because the GAS struct is insufficient + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient */ - switch (Reg->SpaceId) + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - - Status = AcpiOsWriteMemory ( - (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); - break; - - - case ACPI_ADR_SPACE_SYSTEM_IO: - - Status = AcpiHwWritePort ( - (ACPI_IO_ADDRESS) Address, Value, Width); - break; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + if (Reg->BitWidth == 64) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - default: - ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->SpaceId)); - return (AE_BAD_PARAMETER); + if (Reg->BitWidth == 64) + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } } ACPI_DEBUG_PRINT ((ACPI_DB_IO, - "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Width, ACPI_FORMAT_UINT64 (Address), + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); diff --git a/sys/contrib/dev/acpica-unix/include/acapps.h b/sys/contrib/dev/acpica-unix/include/acapps.h index e1f31b791b..4256ef89b2 100644 --- a/sys/contrib/dev/acpica-unix/include/acapps.h +++ b/sys/contrib/dev/acpica-unix/include/acapps.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -121,24 +121,56 @@ #pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ #endif -#define FILE_SUFFIX_DISASSEMBLY "dsl" -#define ACPI_TABLE_FILE_SUFFIX ".dat" +/* Common info for tool signons */ + +#define ACPICA_NAME "Intel ACPI Component Architecture" +#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2011 Intel Corporation" + +#if ACPI_MACHINE_WIDTH == 64 +#define ACPI_WIDTH "-64" -extern UINT8 *DsdtPtr; -extern UINT32 AcpiDsdtLength; -extern UINT8 *AmlStart; -extern UINT32 AmlLength; +#elif ACPI_MACHINE_WIDTH == 32 +#define ACPI_WIDTH "-32" + +#else +#error unknown ACPI_MACHINE_WIDTH +#define ACPI_WIDTH "-??" + +#endif +/* Macros for signons and file headers */ -extern int AcpiGbl_Optind; -extern char *AcpiGbl_Optarg; +#define ACPI_COMMON_SIGNON(UtilityName) \ + "\n%s\n%s version %8.8X%s [%s]\n%s\n\n", \ + ACPICA_NAME, \ + UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, __DATE__, \ + ACPICA_COPYRIGHT +#define ACPI_COMMON_HEADER(UtilityName, Prefix) \ + "%s%s\n%s%s version %8.8X%s [%s]\n%s%s\n%s\n", \ + Prefix, ACPICA_NAME, \ + Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, __DATE__, \ + Prefix, ACPICA_COPYRIGHT, \ + Prefix + +#define FILE_SUFFIX_DISASSEMBLY "dsl" +#define ACPI_TABLE_FILE_SUFFIX ".dat" + + +/* + * getopt + */ int AcpiGetopt( int argc, char **argv, char *opts); +extern int AcpiGbl_Optind; +extern int AcpiGbl_Opterr; +extern char *AcpiGbl_Optarg; + + /* * adisasm */ @@ -151,7 +183,8 @@ AdAmlDisassemble ( BOOLEAN GetAllTables); void -AdPrintStatistics (void); +AdPrintStatistics ( + void); ACPI_STATUS AdFindDsdt( @@ -159,7 +192,8 @@ AdFindDsdt( UINT32 *DsdtLength); void -AdDumpTables (void); +AdDumpTables ( + void); ACPI_STATUS AdGetLocalTables ( @@ -179,7 +213,9 @@ AdDisplayTables ( ACPI_TABLE_HEADER *Table); ACPI_STATUS -AdDisplayStatistics (void); +AdDisplayStatistics ( + void); + /* * adwalk @@ -209,6 +245,7 @@ AcpiDmConvertResourceIndexes ( ACPI_PARSE_OBJECT *ParseTreeRoot, ACPI_NAMESPACE_NODE *NamespaceRoot); + /* * adfile */ @@ -227,11 +264,6 @@ FlSplitInputPathname ( char **OutDirectoryPath, char **OutFilename); -char * -FlGenerateFilename ( - char *InputFilename, - char *Suffix); - char * AdGenerateFilename ( char *Prefix, diff --git a/sys/contrib/dev/acpica-unix/include/accommon.h b/sys/contrib/dev/acpica-unix/include/accommon.h index 690d3cdba9..7a5739eb0d 100644 --- a/sys/contrib/dev/acpica-unix/include/accommon.h +++ b/sys/contrib/dev/acpica-unix/include/accommon.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/acconfig.h b/sys/contrib/dev/acpica-unix/include/acconfig.h index 7b458cc457..c4f9d6f3c9 100644 --- a/sys/contrib/dev/acpica-unix/include/acconfig.h +++ b/sys/contrib/dev/acpica-unix/include/acconfig.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -177,9 +177,9 @@ #define ACPI_MAX_REFERENCE_COUNT 0x800 -/* Size of cached memory mapping for system memory operation region */ +/* Default page size for use in mapping memory for operation regions */ -#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 +#define ACPI_DEFAULT_PAGE_SIZE 4096 /* Must be power of 2 */ /* OwnerId tracking. 8 entries allows for 255 OwnerIds */ @@ -193,6 +193,10 @@ #define ACPI_MAX_LOOP_ITERATIONS 0xFFFF +/* Maximum sleep allowed via Sleep() operator */ + +#define ACPI_MAX_SLEEP 20000 /* Two seconds */ + /****************************************************************************** * @@ -236,7 +240,7 @@ /* Operation regions */ -#define ACPI_NUM_PREDEFINED_REGIONS 8 +#define ACPI_NUM_PREDEFINED_REGIONS 9 #define ACPI_USER_REGION_BEGIN 0x80 /* Maximum SpaceIds for Operation Regions */ @@ -252,9 +256,15 @@ #define ACPI_RSDP_CHECKSUM_LENGTH 20 #define ACPI_RSDP_XCHECKSUM_LENGTH 36 -/* SMBus bidirectional buffer size */ +/* SMBus and IPMI bidirectional buffer size */ #define ACPI_SMBUS_BUFFER_SIZE 34 +#define ACPI_IPMI_BUFFER_SIZE 66 + +/* _SxD and _SxW control methods */ + +#define ACPI_NUM_SxD_METHODS 4 +#define ACPI_NUM_SxW_METHODS 5 /****************************************************************************** diff --git a/sys/contrib/dev/acpica-unix/include/acdebug.h b/sys/contrib/dev/acpica-unix/include/acdebug.h index 7e72094803..c322fa376c 100644 --- a/sys/contrib/dev/acpica-unix/include/acdebug.h +++ b/sys/contrib/dev/acpica-unix/include/acdebug.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ #define __ACDEBUG_H__ -#define ACPI_DEBUG_BUFFER_SIZE 4196 +#define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ typedef struct CommandInfo { @@ -126,13 +126,19 @@ typedef struct CommandInfo } COMMAND_INFO; - typedef struct ArgumentInfo { char *Name; /* Argument Name */ } ARGUMENT_INFO; +typedef struct acpi_execute_walk +{ + UINT32 Count; + UINT32 MaxCount; + +} ACPI_EXECUTE_WALK; + #define PARAM_LIST(pl) pl #define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose) @@ -164,9 +170,9 @@ AcpiDbSingleStep ( /* * dbcmds - debug commands and output routines */ -ACPI_STATUS -AcpiDbDisassembleMethod ( - char *Name); +ACPI_NAMESPACE_NODE * +AcpiDbConvertToNode ( + char *InString); void AcpiDbDisplayTableInfo ( @@ -178,38 +184,53 @@ AcpiDbUnloadAcpiTable ( char *InstanceArg); void -AcpiDbSetMethodBreakpoint ( - char *Location, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); +AcpiDbSendNotify ( + char *Name, + UINT32 Value); void -AcpiDbSetMethodCallBreakpoint ( - ACPI_PARSE_OBJECT *Op); +AcpiDbDisplayInterfaces ( + char *ActionArg, + char *InterfaceNameArg); + +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); void -AcpiDbGetBusInfo ( +AcpiDbDisplayLocks ( void); void -AcpiDbDisassembleAml ( - char *Statements, - ACPI_PARSE_OBJECT *Op); +AcpiDbDisplayResources ( + char *ObjectArg); void -AcpiDbDumpNamespace ( - char *StartArg, - char *DepthArg); +AcpiDbDisplayGpes ( + void); void -AcpiDbDumpNamespaceByOwner ( - char *OwnerArg, - char *DepthArg); +AcpiDbDisplayHandlers ( + void); void -AcpiDbSendNotify ( - char *Name, - UINT32 Value); +AcpiDbGenerateGpe ( + char *GpeArg, + char *BlockArg); + + +/* + * dbmethod - control method commands + */ +void +AcpiDbSetMethodBreakpoint ( + char *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); void AcpiDbSetMethodData ( @@ -218,54 +239,61 @@ AcpiDbSetMethodData ( char *ValueArg); ACPI_STATUS -AcpiDbDisplayObjects ( - char *ObjTypeArg, - char *DisplayCountArg); +AcpiDbDisassembleMethod ( + char *Name); -ACPI_STATUS -AcpiDbFindNameInNamespace ( - char *NameArg); +void +AcpiDbDisassembleAml ( + char *Statements, + ACPI_PARSE_OBJECT *Op); void -AcpiDbSetScope ( - char *Name); +AcpiDbBatchExecute ( + char *CountArg); -ACPI_STATUS -AcpiDbSleep ( - char *ObjectArg); +/* + * dbnames - namespace commands + */ void -AcpiDbFindReferences ( - char *ObjectArg); +AcpiDbSetScope ( + char *Name); void -AcpiDbDisplayLocks ( - void); +AcpiDbDumpNamespace ( + char *StartArg, + char *DepthArg); void -AcpiDbDisplayResources ( - char *ObjectArg); +AcpiDbDumpNamespaceByOwner ( + char *OwnerArg, + char *DepthArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + char *NameArg); void -AcpiDbDisplayGpes ( +AcpiDbCheckPredefinedNames ( void); +ACPI_STATUS +AcpiDbDisplayObjects ( + char *ObjTypeArg, + char *DisplayCountArg); + void AcpiDbCheckIntegrity ( void); void -AcpiDbGenerateGpe ( - char *GpeArg, - char *BlockArg); +AcpiDbFindReferences ( + char *ObjectArg); void -AcpiDbCheckPredefinedNames ( +AcpiDbGetBusInfo ( void); -void -AcpiDbBatchExecute ( - void); /* * dbdisply - debug display commands @@ -313,6 +341,7 @@ AcpiDbDisplayArgumentObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); + /* * dbexec - debugger control method execution */ diff --git a/sys/contrib/dev/acpica-unix/include/acdisasm.h b/sys/contrib/dev/acpica-unix/include/acdisasm.h index 1d82efca48..98a85b1b65 100644 --- a/sys/contrib/dev/acpica-unix/include/acdisasm.h +++ b/sys/contrib/dev/acpica-unix/include/acdisasm.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -125,27 +125,31 @@ #define BLOCK_COMMA_LIST 4 #define ACPI_DEFAULT_RESNAME *(UINT32 *) "__RD" -typedef struct acpi_external_list -{ - char *Path; - char *InternalPath; - struct acpi_external_list *Next; - UINT32 Value; - UINT16 Length; - UINT8 Type; - -} ACPI_EXTERNAL_LIST; +/* + * Raw table data header. Used by disassembler and data table compiler. + * Do not change. + */ +#define ACPI_RAW_TABLE_DATA_HEADER "Raw Table Data" -extern ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; typedef const struct acpi_dmtable_info { UINT8 Opcode; UINT8 Offset; char *Name; + UINT8 Flags; } ACPI_DMTABLE_INFO; +#define DT_LENGTH 0x01 /* Field is a subtable length */ +#define DT_FLAG 0x02 /* Field is a flag value */ +#define DT_NON_ZERO 0x04 /* Field must be non-zero */ + +/* TBD: Not used at this time */ + +#define DT_OPTIONAL 0x08 +#define DT_COUNT 0x10 + /* * Values for Opcode above. * Note: 0-7 must not change, used as a flag shift value @@ -183,16 +187,37 @@ typedef const struct acpi_dmtable_info #define ACPI_DMT_EXIT 30 #define ACPI_DMT_SIG 31 #define ACPI_DMT_FADTPM 32 +#define ACPI_DMT_BUF16 33 +#define ACPI_DMT_IVRS 34 +#define ACPI_DMT_BUFFER 35 +#define ACPI_DMT_PCI_PATH 36 +#define ACPI_DMT_EINJACT 37 +#define ACPI_DMT_EINJINST 38 +#define ACPI_DMT_ERSTACT 39 +#define ACPI_DMT_ERSTINST 40 +#define ACPI_DMT_ACCWIDTH 41 +#define ACPI_DMT_UNICODE 42 +#define ACPI_DMT_UUID 43 +#define ACPI_DMT_DEVICE_PATH 44 +#define ACPI_DMT_LABEL 45 +#define ACPI_DMT_BUF7 46 + typedef void (*ACPI_DMTABLE_HANDLER) ( ACPI_TABLE_HEADER *Table); +typedef +ACPI_STATUS (*ACPI_CMTABLE_HANDLER) ( + void **PFieldList); + typedef struct acpi_dmtable_data { char *Signature; ACPI_DMTABLE_INFO *TableInfo; ACPI_DMTABLE_HANDLER TableHandler; + ACPI_CMTABLE_HANDLER CmTableHandler; + const unsigned char *Template; char *Name; } ACPI_DMTABLE_DATA; @@ -209,11 +234,18 @@ typedef struct acpi_op_walk_info } ACPI_OP_WALK_INFO; +/* + * TBD - another copy of this is in asltypes.h, fix + */ +#ifndef ASL_WALK_CALLBACK_DEFINED typedef ACPI_STATUS (*ASL_WALK_CALLBACK) ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); +#define ASL_WALK_CALLBACK_DEFINED +#endif + typedef struct acpi_resource_tag { @@ -250,10 +282,12 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; @@ -263,15 +297,22 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest3[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest4[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[]; @@ -287,6 +328,9 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMchi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; @@ -300,12 +344,31 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWddt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2]; + /* * dmtable */ +extern ACPI_DMTABLE_DATA AcpiDmTableData[]; + +UINT8 +AcpiDmGenerateChecksum ( + void *Table, + UINT32 Length, + UINT8 OriginalChecksum); + +ACPI_DMTABLE_DATA * +AcpiDmGetTableData ( + char *Signature); + void AcpiDmDumpDataTable ( ACPI_TABLE_HEADER *Table); @@ -363,6 +426,10 @@ void AcpiDmDumpHest ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpMcfg ( ACPI_TABLE_HEADER *Table); @@ -371,6 +438,10 @@ void AcpiDmDumpMadt ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table); + UINT32 AcpiDmDumpRsdp ( ACPI_TABLE_HEADER *Table); @@ -387,6 +458,10 @@ void AcpiDmDumpSrat ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpXsdt ( ACPI_TABLE_HEADER *Table); @@ -446,14 +521,6 @@ void AcpiDmMatchOp ( ACPI_PARSE_OBJECT *Op); -BOOLEAN -AcpiDmCommaIfListMember ( - ACPI_PARSE_OBJECT *Op); - -void -AcpiDmCommaIfFieldMember ( - ACPI_PARSE_OBJECT *Op); - /* * dmnames @@ -526,6 +593,42 @@ AcpiDmIsStringBuffer ( ACPI_PARSE_OBJECT *Op); +/* + * dmextern + */ + +ACPI_STATUS +AcpiDmAddToExternalFileList ( + char *PathList); + +void +AcpiDmClearExternalFileList ( + void); + +void +AcpiDmAddToExternalList ( + ACPI_PARSE_OBJECT *Op, + char *Path, + UINT8 Type, + UINT32 Value); + +void +AcpiDmAddExternalsToNamespace ( + void); + +UINT32 +AcpiDmGetExternalMethodCount ( + void); + +void +AcpiDmClearExternalList ( + void); + +void +AcpiDmEmitExternals ( + void); + + /* * dmresrc */ @@ -560,18 +663,10 @@ ACPI_STATUS AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *Op); -void -AcpiDmIndent ( - UINT32 Level); - void AcpiDmBitList ( UINT16 Mask); -void -AcpiDmDecodeAttribute ( - UINT8 Attribute); - void AcpiDmDescriptorName ( void); @@ -698,10 +793,21 @@ AcpiDmVendorSmallDescriptor ( * dmutils */ void -AcpiDmAddToExternalList ( - char *Path, - UINT8 Type, - UINT32 Value); +AcpiDmDecodeAttribute ( + UINT8 Attribute); + +void +AcpiDmIndent ( + UINT32 Level); + +BOOLEAN +AcpiDmCommaIfListMember ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmCommaIfFieldMember ( + ACPI_PARSE_OBJECT *Op); + /* * dmrestag @@ -715,4 +821,13 @@ AcpiDmCheckResourceReference ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState); + +/* + * acdisasm + */ +void +AdDisassemblerHeader ( + char *Filename); + + #endif /* __ACDISASM_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/acdispat.h b/sys/contrib/dev/acpica-unix/include/acdispat.h index 2aa86232b2..9a47d1dbe6 100644 --- a/sys/contrib/dev/acpica-unix/include/acdispat.h +++ b/sys/contrib/dev/acpica-unix/include/acdispat.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -123,7 +123,7 @@ /* - * dsopcode - support for late evaluation + * dsargs - execution of dynamic arguments for static objects */ ACPI_STATUS AcpiDsGetBufferFieldArguments ( @@ -145,6 +145,24 @@ ACPI_STATUS AcpiDsGetPackageArguments ( ACPI_OPERAND_OBJECT *ObjDesc); + +/* + * dscontrol - support for execution control opcodes + */ +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsopcode - support for late operand evaluation + */ ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE *WalkState, @@ -176,20 +194,6 @@ AcpiDsInitializeRegion ( ACPI_HANDLE ObjHandle); -/* - * dsctrl - Parser/Interpreter interface, control stack routines - */ -ACPI_STATUS -AcpiDsExecBeginControlOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - -ACPI_STATUS -AcpiDsExecEndControlOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - - /* * dsexec - Parser/Interpreter interface, method execution callbacks */ @@ -241,9 +245,14 @@ AcpiDsInitFieldObjects ( /* - * dsload - Parser/Interpreter interface, namespace load callbacks + * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks */ ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber); + +ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp); @@ -252,6 +261,10 @@ ACPI_STATUS AcpiDsLoad1EndOp ( ACPI_WALK_STATE *WalkState); + +/* + * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks + */ ACPI_STATUS AcpiDsLoad2BeginOp ( ACPI_WALK_STATE *WalkState, @@ -261,11 +274,6 @@ ACPI_STATUS AcpiDsLoad2EndOp ( ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiDsInitCallbacks ( - ACPI_WALK_STATE *WalkState, - UINT32 PassNumber); - /* * dsmthdat - method data (locals/args) diff --git a/sys/contrib/dev/acpica-unix/include/acevents.h b/sys/contrib/dev/acpica-unix/include/acevents.h index 0cd5e2e286..a5d759aa40 100644 --- a/sys/contrib/dev/acpica-unix/include/acevents.h +++ b/sys/contrib/dev/acpica-unix/include/acevents.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -128,10 +128,6 @@ ACPI_STATUS AcpiEvInstallXruptHandlers ( void); -ACPI_STATUS -AcpiEvInstallFadtGpes ( - void); - UINT32 AcpiEvFixedEventDetect ( void); @@ -167,20 +163,26 @@ AcpiEvQueueNotifyRequest ( /* - * evgpe - GPE handling and dispatch + * evgpe - Low-level GPE support */ +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList); + ACPI_STATUS -AcpiEvUpdateGpeEnableMasks ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - UINT8 Type); +AcpiEvUpdateGpeEnableMask ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_STATUS AcpiEvEnableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - BOOLEAN WriteToHardware); + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvAddGpeReference ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_STATUS -AcpiEvDisableGpe ( +AcpiEvRemoveGpeReference ( ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_GPE_EVENT_INFO * @@ -188,25 +190,19 @@ AcpiEvGetGpeEventInfo ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber); - -/* - * evgpeblk - */ -BOOLEAN -AcpiEvValidGpeEvent ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); +ACPI_GPE_EVENT_INFO * +AcpiEvLowGetGpeInfo ( + UINT32 GpeNumber, + ACPI_GPE_BLOCK_INFO *GpeBlock); ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - void *Context); +AcpiEvFinishGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); -ACPI_STATUS -AcpiEvDeleteGpeHandlers ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context); +/* + * evgpeblk - Upper-level GPE block support + */ ACPI_STATUS AcpiEvCreateGpeBlock ( ACPI_NAMESPACE_NODE *GpeDevice, @@ -218,8 +214,9 @@ AcpiEvCreateGpeBlock ( ACPI_STATUS AcpiEvInitializeGpeBlock ( - ACPI_NAMESPACE_NODE *GpeDevice, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); ACPI_STATUS AcpiEvDeleteGpeBlock ( @@ -227,25 +224,59 @@ AcpiEvDeleteGpeBlock ( UINT32 AcpiEvGpeDispatch ( + ACPI_NAMESPACE_NODE *GpeDevice, ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 GpeNumber); -UINT32 -AcpiEvGpeDetect ( - ACPI_GPE_XRUPT_INFO *GpeXruptList); +/* + * evgpeinit - GPE initialization and update + */ +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + +void +AcpiEvUpdateGpes ( + ACPI_OWNER_ID TableOwnerId); ACPI_STATUS -AcpiEvSetGpeType ( - ACPI_GPE_EVENT_INFO *GpeEventInfo, - UINT8 Type); +AcpiEvMatchGpeMethod ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +/* + * evgpeutil - GPE utilities + */ ACPI_STATUS -AcpiEvCheckForWakeOnlyGpe ( +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); + +BOOLEAN +AcpiEvValidGpeEvent ( ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_STATUS -AcpiEvGpeInitialize ( - void); +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber); + +ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); /* @@ -265,7 +296,7 @@ AcpiEvAddressSpaceDispatch ( UINT32 Function, UINT32 RegionOffset, UINT32 BitWidth, - ACPI_INTEGER *Value); + UINT64 *Value); ACPI_STATUS AcpiEvAttachRegion ( diff --git a/sys/contrib/dev/acpica-unix/include/acexcep.h b/sys/contrib/dev/acpica-unix/include/acexcep.h index dfe2e2ee73..0985258f97 100644 --- a/sys/contrib/dev/acpica-unix/include/acexcep.h +++ b/sys/contrib/dev/acpica-unix/include/acexcep.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -162,7 +162,7 @@ #define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) #define AE_ABORT_METHOD (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) #define AE_SAME_HANDLER (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) -#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) +#define AE_NO_HANDLER (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) #define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) #define AE_CODE_ENV_MAX 0x001B @@ -293,7 +293,7 @@ char const *AcpiGbl_ExceptionNames_Env[] = "AE_NO_GLOBAL_LOCK", "AE_ABORT_METHOD", "AE_SAME_HANDLER", - "AE_WAKE_ONLY_GPE", + "AE_NO_HANDLER", "AE_OWNER_ID_LIMIT" }; diff --git a/sys/contrib/dev/acpica-unix/include/acglobal.h b/sys/contrib/dev/acpica-unix/include/acglobal.h index 4d7b2f3d65..fccf45ee98 100644 --- a/sys/contrib/dev/acpica-unix/include/acglobal.h +++ b/sys/contrib/dev/acpica-unix/include/acglobal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -131,8 +131,11 @@ #define ACPI_INIT_GLOBAL(a,b) a #endif + #ifdef DEFINE_ACPI_GLOBALS +/* Public globals, available from outside ACPICA subsystem */ + /***************************************************************************** * * Runtime configuration (static defaults that can be overriden at runtime) @@ -153,7 +156,7 @@ * 5) Allow unresolved references (invalid target name) in package objects * 6) Enable warning messages for behavior that is not ACPI spec compliant */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); /* * Automatically serialize ALL control methods? Default is FALSE, meaning @@ -161,30 +164,52 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE) * Only change this if the ASL code is poorly written and cannot handle * reentrancy even though methods are marked "NotSerialized". */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); /* * Create the predefined _OSI method in the namespace? Default is TRUE * because ACPI CA is fully compatible with other ACPI implementations. * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); /* - * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and - * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only - * be enabled just before going to sleep. + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); -#endif +/* + * Optionally enable output from the AML Debug Object. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableAmlDebugObject, FALSE); /* - * Optionally use default values for the ACPI register widths. Set this to - * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + * Optionally copy the entire DSDT to local memory (instead of simply + * mapping it.) There are some BIOSs that corrupt or replace the original + * DSDT, creating the need for this option. Default is FALSE, do not copy + * the DSDT. */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CopyDsdtLocally, FALSE); +/* + * Optionally truncate I/O addresses to 16 bits. Provides compatibility + * with other ACPI implementations. NOTE: During ACPICA initialization, + * this value is set to TRUE if any Windows OSI strings have been + * requested by the BIOS. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_TruncateIoAddresses, FALSE); + + +/* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ + +ACPI_TABLE_FADT AcpiGbl_FADT; +UINT32 AcpiCurrentGpeCount; +UINT32 AcpiGbl_TraceFlags; +ACPI_NAME AcpiGbl_TraceMethodName; +BOOLEAN AcpiGbl_SystemAwakeAndRunning; + +#endif /***************************************************************************** * @@ -193,15 +218,10 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE ****************************************************************************/ /* - * AcpiGbl_RootTableList is the master list of ACPI tables found in the - * RSDT/XSDT. - * - * AcpiGbl_FADT is a local copy of the FADT, converted to a common format. + * AcpiGbl_RootTableList is the master list of ACPI tables that were + * found in the RSDT/XSDT. */ -ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; -#ifdef DEFINE_ACPI_GLOBALS -ACPI_EXTERN ACPI_TABLE_FADT AcpiGbl_FADT; -#endif +ACPI_EXTERN ACPI_TABLE_LIST AcpiGbl_RootTableList; ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; /* These addresses are calculated from the FADT Event Block addresses */ @@ -212,6 +232,11 @@ ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; +/* DSDT information. Used to check for DSDT corruption */ + +ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; +ACPI_EXTERN ACPI_TABLE_HEADER AcpiGbl_OriginalDsdtHeader; + /* * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is * determined by the revision of the DSDT: If the DSDT revision is less than @@ -252,6 +277,10 @@ ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ +/* Mutex for _OSI support */ + +ACPI_EXTERN ACPI_MUTEX AcpiGbl_OsiMutex; + /* Reader/Writer lock is used for namespace walk and dynamic table unload */ ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; @@ -280,7 +309,7 @@ ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_TABLE_HANDLER AcpiGbl_TableHandler; ACPI_EXTERN void *AcpiGbl_TableHandlerContext; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; - +ACPI_EXTERN ACPI_INTERFACE_HANDLER AcpiGbl_InterfaceHandler; /* Owner ID support */ @@ -288,6 +317,10 @@ ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MAS ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; +/* Initialization sequencing */ + +ACPI_EXTERN BOOLEAN AcpiGbl_RegMethodsExecuted; + /* Misc */ ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; @@ -299,8 +332,8 @@ ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; -ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; ACPI_EXTERN UINT8 AcpiGbl_OsiData; +ACPI_EXTERN ACPI_INTERFACE_INFO *AcpiGbl_SupportedInterfaces; #ifndef DEFINE_ACPI_GLOBALS @@ -318,7 +351,8 @@ extern char const *AcpiGbl_ExceptionNames_Ctrl[]; extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; -extern const char *AcpiGbl_HighestDstateNames[4]; +extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; +extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; #endif @@ -331,6 +365,7 @@ extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_ ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; +ACPI_EXTERN BOOLEAN AcpiGbl_DisableMemTracking; #endif @@ -349,6 +384,8 @@ ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ModuleCodeList; + extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; @@ -394,13 +431,13 @@ ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; * ****************************************************************************/ -extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; -ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN UINT8 AcpiGbl_AllGpesInitialized; ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; -#ifdef DEFINE_ACPI_GLOBALS -ACPI_EXTERN UINT32 AcpiCurrentGpeCount; -#endif +ACPI_EXTERN ACPI_GBL_EVENT_HANDLER AcpiGbl_GlobalEventHandler; +ACPI_EXTERN void *AcpiGbl_GlobalEventHandlerContext; +ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; +extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; /***************************************************************************** @@ -426,10 +463,6 @@ ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; -#ifdef DEFINE_ACPI_GLOBALS -ACPI_EXTERN ACPI_NAME AcpiGbl_TraceMethodName; -ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; -#endif /***************************************************************************** @@ -444,6 +477,8 @@ ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; +ACPI_EXTERN ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; +ACPI_EXTERN ACPI_EXTERNAL_FILE *AcpiGbl_ExternalFileList; #endif diff --git a/sys/contrib/dev/acpica-unix/include/achware.h b/sys/contrib/dev/acpica-unix/include/achware.h index 05da01b44d..32b9a0110a 100644 --- a/sys/contrib/dev/acpica-unix/include/achware.h +++ b/sys/contrib/dev/acpica-unix/include/achware.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -141,6 +141,22 @@ AcpiHwGetMode ( /* * hwregs - ACPI Register I/O */ +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address); + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg); + ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo ( UINT32 RegisterId); @@ -184,13 +200,15 @@ AcpiHwWritePort ( /* * hwgpe - GPE support */ -ACPI_STATUS -AcpiHwLowDisableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); +UINT32 +AcpiHwGetGpeRegisterBit ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo); ACPI_STATUS -AcpiHwWriteGpeEnableReg ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); +AcpiHwLowSetGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 Action); ACPI_STATUS AcpiHwDisableGpeBlock ( @@ -232,6 +250,16 @@ AcpiHwEnableRuntimeGpeBlock ( void *Context); +/* + * hwpci - PCI configuration support + */ +ACPI_STATUS +AcpiHwDerivePciId ( + ACPI_PCI_ID *PciId, + ACPI_HANDLE RootPciDevice, + ACPI_HANDLE PciRegion); + + /* * hwtimer - ACPI Timer prototypes */ diff --git a/sys/contrib/dev/acpica-unix/include/acinterp.h b/sys/contrib/dev/acpica-unix/include/acinterp.h index b0f4b92185..8cb1e3b1d0 100644 --- a/sys/contrib/dev/acpica-unix/include/acinterp.h +++ b/sys/contrib/dev/acpica-unix/include/acinterp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -202,6 +202,16 @@ AcpiExConvertToTargetType ( ACPI_WALK_STATE *WalkState); +/* + * exdebug - AML debug object + */ +void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + + /* * exfield - ACPI AML (p-code) execution - field manipulation */ @@ -214,13 +224,13 @@ AcpiExCommonBufferSetup ( ACPI_STATUS AcpiExWriteWithUpdateRule ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Mask, - ACPI_INTEGER FieldValue, + UINT64 Mask, + UINT64 FieldValue, UINT32 FieldDatumByteOffset); void AcpiExGetBufferDatum( - ACPI_INTEGER *Datum, + UINT64 *Datum, void *Buffer, UINT32 BufferLength, UINT32 ByteGranularity, @@ -228,7 +238,7 @@ AcpiExGetBufferDatum( void AcpiExSetBufferDatum ( - ACPI_INTEGER MergedDatum, + UINT64 MergedDatum, void *Buffer, UINT32 BufferLength, UINT32 ByteGranularity, @@ -266,7 +276,7 @@ ACPI_STATUS AcpiExAccessRegion ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, + UINT64 *Value, UINT32 ReadWrite); @@ -296,8 +306,8 @@ AcpiExDoConcatenate ( ACPI_STATUS AcpiExDoLogicalNumericOp ( UINT16 Opcode, - ACPI_INTEGER Integer0, - ACPI_INTEGER Integer1, + UINT64 Integer0, + UINT64 Integer1, BOOLEAN *LogicalResult); ACPI_STATUS @@ -307,11 +317,11 @@ AcpiExDoLogicalOp ( ACPI_OPERAND_OBJECT *Operand1, BOOLEAN *LogicalResult); -ACPI_INTEGER +UINT64 AcpiExDoMathOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1); + UINT64 Operand0, + UINT64 Operand1); ACPI_STATUS AcpiExCreateMutex ( @@ -424,8 +434,8 @@ AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS -AcpiExSystemDoSuspend( - ACPI_INTEGER Time); +AcpiExSystemDoSleep( + UINT64 Time); ACPI_STATUS AcpiExSystemDoStall ( @@ -696,13 +706,13 @@ AcpiExReleaseGlobalLock ( void AcpiExEisaIdToString ( - UINT32 NumericId, - char *OutString); + char *Dest, + UINT64 CompressedId); void -AcpiExUnsignedIntegerToString ( - ACPI_INTEGER Value, - char *OutString); +AcpiExIntegerToString ( + char *Dest, + UINT64 Value); /* @@ -713,7 +723,7 @@ AcpiExSystemMemorySpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -722,7 +732,7 @@ AcpiExSystemIoSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -731,7 +741,7 @@ AcpiExPciConfigSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -740,7 +750,7 @@ AcpiExCmosSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -749,7 +759,7 @@ AcpiExPciBarSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -758,7 +768,7 @@ AcpiExEmbeddedControllerSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -767,7 +777,7 @@ AcpiExSmBusSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -777,7 +787,7 @@ AcpiExDataTableSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); diff --git a/sys/contrib/dev/acpica-unix/include/aclocal.h b/sys/contrib/dev/acpica-unix/include/aclocal.h index 99955c31bf..9436f57f5a 100644 --- a/sys/contrib/dev/acpica-unix/include/aclocal.h +++ b/sys/contrib/dev/acpica-unix/include/aclocal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -165,25 +165,6 @@ union acpi_parse_object; #define ACPI_MAX_MUTEX 7 #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -#ifdef DEFINE_ACPI_GLOBALS - -/* Debug names for the mutexes above */ - -static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = -{ - "ACPI_MTX_Interpreter", - "ACPI_MTX_Namespace", - "ACPI_MTX_Tables", - "ACPI_MTX_Events", - "ACPI_MTX_Caches", - "ACPI_MTX_Memory", - "ACPI_MTX_CommandComplete", - "ACPI_MTX_CommandReady" -}; - -#endif -#endif /* Lock structure for reader/writer interfaces */ @@ -275,8 +256,9 @@ typedef struct acpi_namespace_node UINT8 Flags; /* Miscellaneous flags */ ACPI_OWNER_ID OwnerId; /* Node creator */ ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ + struct acpi_namespace_node *Parent; /* Parent node */ struct acpi_namespace_node *Child; /* First child */ - struct acpi_namespace_node *Peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ + struct acpi_namespace_node *Peer; /* First peer */ /* * The following fields are used by the ASL compiler and disassembler only @@ -292,7 +274,7 @@ typedef struct acpi_namespace_node /* Namespace Node flags */ -#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ +#define ANOBJ_RESERVED 0x01 /* Available for use */ #define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ @@ -307,16 +289,16 @@ typedef struct acpi_namespace_node #define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ -/* One internal RSDT for table management */ +/* Internal ACPI table management - master table list */ -typedef struct acpi_internal_rsdt +typedef struct acpi_table_list { - ACPI_TABLE_DESC *Tables; - UINT32 Count; - UINT32 Size; + ACPI_TABLE_DESC *Tables; /* Table descriptor array */ + UINT32 CurrentTableCount; /* Tables currently in the array */ + UINT32 MaxTableCount; /* Max tables array will hold */ UINT8 Flags; -} ACPI_INTERNAL_RSDT; +} ACPI_TABLE_LIST; /* Flags for above */ @@ -493,6 +475,24 @@ typedef union acpi_predefined_info } ACPI_PREDEFINED_INFO; + +/* Data block used during object validation */ + +typedef struct acpi_predefined_data +{ + char *Pathname; + const ACPI_PREDEFINED_INFO *Predefined; + union acpi_operand_object *ParentPackage; + UINT32 Flags; + UINT8 NodeFlags; + +} ACPI_PREDEFINED_DATA; + +/* Defines for Flags field above */ + +#define ACPI_OBJECT_REPAIRED 1 + + /* * Bitmapped return value types * Note: the actual data types must be contiguous, a loop in nspredef.c @@ -518,18 +518,25 @@ typedef union acpi_predefined_info /* Dispatch info for each GPE -- either a method or handler, cannot be both */ -typedef struct acpi_handler_info +typedef struct acpi_gpe_handler_info { - ACPI_EVENT_HANDLER Address; /* Address of handler, if any */ + ACPI_GPE_HANDLER Address; /* Address of handler, if any */ void *Context; /* Context to be passed to handler */ ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level (saved) */ + UINT8 OriginalFlags; /* Original (pre-handler) GPE info */ + BOOLEAN OriginallyEnabled; /* True if GPE was originally enabled */ -} ACPI_HANDLER_INFO; +} ACPI_GPE_HANDLER_INFO; +/* + * GPE dispatch info. At any time, the GPE can have at most one type + * of dispatch - Method, Handler, or Implicit Notify. + */ typedef union acpi_gpe_dispatch_info { ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ - struct acpi_handler_info *Handler; + struct acpi_gpe_handler_info *Handler; /* Installed GPE handler */ + ACPI_NAMESPACE_NODE *DeviceNode; /* Parent _PRW device for implicit notify */ } ACPI_GPE_DISPATCH_INFO; @@ -543,6 +550,7 @@ typedef struct acpi_gpe_event_info struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ UINT8 Flags; /* Misc info about this GPE */ UINT8 GpeNumber; /* This GPE */ + UINT8 RuntimeCount; /* References to a run GPE */ } ACPI_GPE_EVENT_INFO; @@ -572,7 +580,9 @@ typedef struct acpi_gpe_block_info ACPI_GPE_EVENT_INFO *EventInfo; /* One for each GPE */ ACPI_GENERIC_ADDRESS BlockAddress; /* Base address of the block */ UINT32 RegisterCount; /* Number of register pairs in block */ + UINT16 GpeCount; /* Number of individual GPEs in block */ UINT8 BlockBaseNumber;/* Base GPE number for this block */ + BOOLEAN Initialized; /* TRUE if this block is initialized */ } ACPI_GPE_BLOCK_INFO; @@ -591,6 +601,9 @@ typedef struct acpi_gpe_walk_info { ACPI_NAMESPACE_NODE *GpeDevice; ACPI_GPE_BLOCK_INFO *GpeBlock; + UINT16 Count; + ACPI_OWNER_ID OwnerId; + BOOLEAN ExecuteByOwnerId; } ACPI_GPE_WALK_INFO; @@ -835,8 +848,7 @@ typedef struct acpi_opcode_info typedef union acpi_parse_value { - ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ - UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ + UINT64 Integer; /* Integer constant (Up to 64 bits) */ UINT32 Size; /* bytelist or field size */ char *String; /* NULL terminated string */ UINT8 *Buffer; /* buffer or string */ @@ -1056,6 +1068,7 @@ typedef struct acpi_bit_register_info ACPI_BITMASK_POWER_BUTTON_STATUS | \ ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ ACPI_BITMASK_RT_CLOCK_STATUS | \ + ACPI_BITMASK_PCIEXP_WAKE_STATUS | \ ACPI_BITMASK_WAKE_STATUS) #define ACPI_BITMASK_TIMER_ENABLE 0x0001 @@ -1110,16 +1123,25 @@ typedef struct acpi_bit_register_info #define ACPI_OSI_WIN_XP_SP2 0x05 #define ACPI_OSI_WINSRV_2003_SP1 0x06 #define ACPI_OSI_WIN_VISTA 0x07 +#define ACPI_OSI_WINSRV_2008 0x08 +#define ACPI_OSI_WIN_VISTA_SP1 0x09 +#define ACPI_OSI_WIN_VISTA_SP2 0x0A +#define ACPI_OSI_WIN_7 0x0B #define ACPI_ALWAYS_ILLEGAL 0x00 typedef struct acpi_interface_info { - char *Name; - UINT8 Value; + char *Name; + struct acpi_interface_info *Next; + UINT8 Flags; + UINT8 Value; } ACPI_INTERFACE_INFO; +#define ACPI_OSI_INVALID 0x01 +#define ACPI_OSI_DYNAMIC 0x02 + typedef struct acpi_port_info { char *Name; @@ -1196,6 +1218,37 @@ typedef struct acpi_port_info #define ACPI_ASCII_ZERO 0x30 +/***************************************************************************** + * + * Disassembler + * + ****************************************************************************/ + +typedef struct acpi_external_list +{ + char *Path; + char *InternalPath; + struct acpi_external_list *Next; + UINT32 Value; + UINT16 Length; + UINT8 Type; + UINT8 Flags; + +} ACPI_EXTERNAL_LIST; + +/* Values for Flags field above */ + +#define ACPI_IPATH_ALLOCATED 0x01 + + +typedef struct acpi_external_file +{ + char *Path; + struct acpi_external_file *Next; + +} ACPI_EXTERNAL_FILE; + + /***************************************************************************** * * Debugger @@ -1207,7 +1260,7 @@ typedef struct acpi_db_method_info ACPI_HANDLE MainThreadGate; ACPI_HANDLE ThreadCompleteGate; ACPI_HANDLE InfoGate; - UINT32 *Threads; + ACPI_THREAD_ID *Threads; UINT32 NumThreads; UINT32 NumCreated; UINT32 NumCompleted; diff --git a/sys/contrib/dev/acpica-unix/include/acmacros.h b/sys/contrib/dev/acpica-unix/include/acmacros.h index b9c323ebd7..5cc284efdf 100644 --- a/sys/contrib/dev/acpica-unix/include/acmacros.h +++ b/sys/contrib/dev/acpica-unix/include/acmacros.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -335,8 +335,8 @@ * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position */ -#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((UINT32) (position)))) -#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((UINT32) (position))) +#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((UINT32) (position)))) +#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((UINT32) (position))) /* Bitfields within ACPI registers */ @@ -400,8 +400,10 @@ * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ -#define ACPI_ERROR_NAMESPACE(s, e) AcpiNsReportError (AE_INFO, s, e); -#define ACPI_ERROR_METHOD(s, n, p, e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); +#define ACPI_ERROR_NAMESPACE(s, e) AcpiUtNamespaceError (AE_INFO, s, e); +#define ACPI_ERROR_METHOD(s, n, p, e) AcpiUtMethodError (AE_INFO, s, n, p, e); +#define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist +#define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist #else @@ -409,6 +411,8 @@ #define ACPI_ERROR_NAMESPACE(s, e) #define ACPI_ERROR_METHOD(s, n, p, e) +#define ACPI_WARN_PREDEFINED(plist) +#define ACPI_INFO_PREDEFINED(plist) #endif /* ACPI_NO_ERROR_MESSAGES */ @@ -469,16 +473,16 @@ AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \ return (_s); }) #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ - register ACPI_INTEGER _s = (s); \ + register UINT64 _s = (s); \ AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, _s); \ return (_s); }) #define return_UINT8(s) ACPI_DO_WHILE0 ({ \ register UINT8 _s = (UINT8) (s); \ - AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (UINT64) _s); \ return (_s); }) #define return_UINT32(s) ACPI_DO_WHILE0 ({ \ register UINT32 _s = (UINT32) (s); \ - AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (UINT64) _s); \ return (_s); }) #else /* Use original less-safe macros */ @@ -489,7 +493,7 @@ AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \ return((s)); }) #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ - AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (UINT64) (s)); \ return((s)); }) #define return_UINT8(s) return_VALUE(s) #define return_UINT32(s) return_VALUE(s) diff --git a/sys/contrib/dev/acpica-unix/include/acnames.h b/sys/contrib/dev/acpica-unix/include/acnames.h index eb9944aa16..3fbc61cc9b 100644 --- a/sys/contrib/dev/acpica-unix/include/acnames.h +++ b/sys/contrib/dev/acpica-unix/include/acnames.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/acnamesp.h b/sys/contrib/dev/acpica-unix/include/acnamesp.h index 3f9a6ce6fa..0437a277fe 100644 --- a/sys/contrib/dev/acpica-unix/include/acnamesp.h +++ b/sys/contrib/dev/acpica-unix/include/acnamesp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -146,6 +146,14 @@ #define ACPI_NS_WALK_UNLOCK 0x01 #define ACPI_NS_WALK_TEMP_NODES 0x02 +/* Object is not a package element */ + +#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX + +/* Always emit warning message, not dependent on node flags */ + +#define ACPI_WARN_ALWAYS 0 + /* * nsinit - Namespace initialization @@ -181,7 +189,8 @@ AcpiNsWalkNamespace ( ACPI_HANDLE StartObject, UINT32 MaxDepth, UINT32 Flags, - ACPI_WALK_CALLBACK UserFunction, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, void *Context, void **ReturnValue); @@ -240,6 +249,10 @@ void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node); +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node); + void AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentHandle); @@ -310,6 +323,10 @@ ACPI_STATUS AcpiNsEvaluate ( ACPI_EVALUATE_INFO *Info); +void +AcpiNsExecModuleCodeList ( + void); + /* * nspredef - Support for predefined/reserved names @@ -411,6 +428,48 @@ AcpiNsGetAttachedData ( void **Data); +/* + * nsrepair - General return object repair for all + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiNsRepairNullElement ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * nsrepair2 - Return object repair for specific + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + + /* * nssearch - Namespace searching and entry */ @@ -454,22 +513,6 @@ UINT32 AcpiNsLocal ( ACPI_OBJECT_TYPE Type); -void -AcpiNsReportError ( - const char *ModuleName, - UINT32 LineNumber, - const char *InternalName, - ACPI_STATUS LookupStatus); - -void -AcpiNsReportMethodError ( - const char *ModuleName, - UINT32 LineNumber, - const char *Message, - ACPI_NAMESPACE_NODE *Node, - const char *Path, - ACPI_STATUS LookupStatus); - void AcpiNsPrintNodePathname ( ACPI_NAMESPACE_NODE *Node, @@ -496,24 +539,11 @@ AcpiNsExternalizeName ( char **ConvertedName); ACPI_NAMESPACE_NODE * -AcpiNsMapHandleToNode ( +AcpiNsValidateHandle ( ACPI_HANDLE Handle); -ACPI_HANDLE -AcpiNsConvertEntryToHandle( - ACPI_NAMESPACE_NODE *Node); - void AcpiNsTerminate ( void); -ACPI_NAMESPACE_NODE * -AcpiNsGetParentNode ( - ACPI_NAMESPACE_NODE *Node); - - -ACPI_NAMESPACE_NODE * -AcpiNsGetNextValidNode ( - ACPI_NAMESPACE_NODE *Node); - #endif /* __ACNAMESP_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/acobject.h b/sys/contrib/dev/acpica-unix/include/acobject.h index 5941859209..6a6ad334e7 100644 --- a/sys/contrib/dev/acpica-unix/include/acobject.h +++ b/sys/contrib/dev/acpica-unix/include/acobject.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -164,12 +164,12 @@ /* Values for Flag byte above */ -#define AOPOBJ_AML_CONSTANT 0x01 -#define AOPOBJ_STATIC_POINTER 0x02 -#define AOPOBJ_DATA_VALID 0x04 -#define AOPOBJ_OBJECT_INITIALIZED 0x08 -#define AOPOBJ_SETUP_COMPLETE 0x10 -#define AOPOBJ_SINGLE_DATUM 0x20 +#define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */ +#define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */ +#define AOPOBJ_DATA_VALID 0x04 /* Object is intialized and data is valid */ +#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */ +#define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */ +#define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */ /****************************************************************************** @@ -189,7 +189,7 @@ typedef struct acpi_object_integer { ACPI_OBJECT_COMMON_HEADER UINT8 Fill[3]; /* Prevent warning on some compilers */ - ACPI_INTEGER Value; + UINT64 Value; } ACPI_OBJECT_INTEGER; @@ -282,18 +282,31 @@ typedef struct acpi_object_region typedef struct acpi_object_method { ACPI_OBJECT_COMMON_HEADER - UINT8 MethodFlags; + UINT8 InfoFlags; UINT8 ParamCount; UINT8 SyncLevel; union acpi_operand_object *Mutex; UINT8 *AmlStart; - ACPI_INTERNAL_METHOD Implementation; + union + { + ACPI_INTERNAL_METHOD Implementation; + union acpi_operand_object *Handler; + } Dispatch; + UINT32 AmlLength; UINT8 ThreadCount; ACPI_OWNER_ID OwnerId; } ACPI_OBJECT_METHOD; +/* Flags for InfoFlags field above */ + +#define ACPI_METHOD_MODULE_LEVEL 0x01 /* Method is actually module-level code */ +#define ACPI_METHOD_INTERNAL_ONLY 0x02 /* Method is implemented internally (_OSI) */ +#define ACPI_METHOD_SERIALIZED 0x04 /* Method is serialized */ +#define ACPI_METHOD_SERIALIZED_PENDING 0x08 /* Method is to be marked serialized */ +#define ACPI_METHOD_MODIFIED_NAMESPACE 0x10 /* Method modified the namespace */ + /****************************************************************************** * @@ -379,7 +392,6 @@ typedef struct acpi_object_thermal_zone UINT32 BaseByteOffset; /* Byte offset within containing object */\ UINT32 Value; /* Value to store into the Bank or Index register */\ UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ - UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */ typedef struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ diff --git a/sys/contrib/dev/acpica-unix/include/acopcode.h b/sys/contrib/dev/acpica-unix/include/acopcode.h index bb309c78d3..5e42cc5b80 100644 --- a/sys/contrib/dev/acpica-unix/include/acopcode.h +++ b/sys/contrib/dev/acpica-unix/include/acopcode.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/acoutput.h b/sys/contrib/dev/acpica-unix/include/acoutput.h index 2b796b541a..0b319c8b10 100644 --- a/sys/contrib/dev/acpica-unix/include/acoutput.h +++ b/sys/contrib/dev/acpica-unix/include/acoutput.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -143,8 +143,9 @@ #define ACPI_TOOLS 0x00002000 #define ACPI_EXAMPLE 0x00004000 #define ACPI_DRIVER 0x00008000 +#define DT_COMPILER 0x00010000 -#define ACPI_ALL_COMPONENTS 0x0000FFFF +#define ACPI_ALL_COMPONENTS 0x0001FFFF #define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) /* Component IDs reserved for ACPI drivers */ @@ -158,7 +159,8 @@ #define ACPI_LV_INIT 0x00000001 #define ACPI_LV_DEBUG_OBJECT 0x00000002 #define ACPI_LV_INFO 0x00000004 -#define ACPI_LV_ALL_EXCEPTIONS 0x00000007 +#define ACPI_LV_REPAIR 0x00000008 +#define ACPI_LV_ALL_EXCEPTIONS 0x0000000F /* Trace verbosity level 1 [Standard Trace Level] */ @@ -217,6 +219,7 @@ #define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) #define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) #define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) +#define ACPI_DB_REPAIR ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR) #define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) /* Trace level -- also used in the global "DebugLevel" */ @@ -248,20 +251,26 @@ /* Defaults for DebugLevel, debug and normal */ -#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT) -#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT) +#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) +#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) #if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) /* - * Module name is included in both debug and non-debug versions primarily for - * error messages. The __FILE__ macro is not very useful for this, because it - * often includes the entire pathname to the module + * The module name is used primarily for error and debug messages. + * The __FILE__ macro is not very useful for this, because it + * usually includes the entire pathname to the module making the + * debug output difficult to read. */ #define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; #else +/* + * For the no-debug and no-error-msg cases, we must at least define + * a null module name. + */ #define ACPI_MODULE_NAME(Name) +#define _AcpiModuleName "" #endif /* @@ -279,6 +288,7 @@ #define ACPI_WARNING(plist) AcpiWarning plist #define ACPI_EXCEPTION(plist) AcpiException plist #define ACPI_ERROR(plist) AcpiError plist +#define ACPI_DEBUG_OBJECT(obj,l,i) AcpiExDoDebugObject(obj,l,i) #else @@ -288,6 +298,7 @@ #define ACPI_WARNING(plist) #define ACPI_EXCEPTION(plist) #define ACPI_ERROR(plist) +#define ACPI_DEBUG_OBJECT(obj,l,i) #endif /* ACPI_NO_ERROR_MESSAGES */ diff --git a/sys/contrib/dev/acpica-unix/include/acparser.h b/sys/contrib/dev/acpica-unix/include/acparser.h index b65177b10d..3ea2096c9c 100644 --- a/sys/contrib/dev/acpica-unix/include/acparser.h +++ b/sys/contrib/dev/acpica-unix/include/acparser.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -137,6 +137,7 @@ #define ACPI_PARSE_DEFERRED_OP 0x0100 #define ACPI_PARSE_DISASSEMBLE 0x0200 +#define ACPI_PARSE_MODULE_LEVEL 0x0400 /****************************************************************************** * diff --git a/sys/contrib/dev/acpica-unix/include/acpi.h b/sys/contrib/dev/acpica-unix/include/acpi.h index ac0af0387b..fcc027d9ae 100644 --- a/sys/contrib/dev/acpica-unix/include/acpi.h +++ b/sys/contrib/dev/acpica-unix/include/acpi.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/acpiosxf.h b/sys/contrib/dev/acpica-unix/include/acpiosxf.h index 4f41aeb19e..7c884712d6 100644 --- a/sys/contrib/dev/acpica-unix/include/acpiosxf.h +++ b/sys/contrib/dev/acpica-unix/include/acpiosxf.h @@ -12,7 +12,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -306,21 +306,10 @@ void * AcpiOsAcquireObject ( ACPI_CACHE_T *Cache); -#ifndef ACPI_DEBUG_CACHE ACPI_STATUS AcpiOsReleaseObject ( ACPI_CACHE_T *Cache, void *Object); -#define ACPI_OS_RELEASE_OBJECT(c, o) AcpiOsReleaseObject((c), (o)) -#else -ACPI_STATUS -_AcpiOsReleaseObject ( - ACPI_CACHE_T *Cache, - void *Object, - const char *, int); -#define ACPI_OS_RELEASE_OBJECT(c, o) \ - _AcpiOsReleaseObject((c), (o), __func__, __LINE__) -#endif /* @@ -357,7 +346,7 @@ AcpiOsWaitEventsComplete ( void AcpiOsSleep ( - ACPI_INTEGER Milliseconds); + UINT64 Milliseconds); void AcpiOsStall ( @@ -405,34 +394,20 @@ ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Reg, - void *Value, + UINT64 *Value, UINT32 Width); ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Reg, - ACPI_INTEGER Value, + UINT64 Value, UINT32 Width); -/* - * Interim function needed for PCI IRQ routing - */ -void -AcpiOsDerivePciId( - ACPI_HANDLE Rhandle, - ACPI_HANDLE Chandle, - ACPI_PCI_ID **PciId); - - /* * Miscellaneous */ -ACPI_STATUS -AcpiOsValidateInterface ( - char *Interface); - BOOLEAN AcpiOsReadable ( void *Pointer, diff --git a/sys/contrib/dev/acpica-unix/include/acpixf.h b/sys/contrib/dev/acpica-unix/include/acpixf.h index b383235be8..b067636d52 100644 --- a/sys/contrib/dev/acpica-unix/include/acpixf.h +++ b/sys/contrib/dev/acpica-unix/include/acpixf.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,7 +120,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20090521 +#define ACPI_CA_VERSION 0x20110211 #include "actypes.h" #include "actbl.h" @@ -130,21 +130,28 @@ */ extern UINT32 AcpiCurrentGpeCount; extern ACPI_TABLE_FADT AcpiGbl_FADT; +extern BOOLEAN AcpiGbl_SystemAwakeAndRunning; -/* Run-time configuration */ +/* Runtime configuration of debug print levels */ extern UINT32 AcpiDbgLevel; extern UINT32 AcpiDbgLayer; + +/* ACPICA runtime options */ + extern UINT8 AcpiGbl_EnableInterpreterSlack; extern UINT8 AcpiGbl_AllMethodsSerialized; extern UINT8 AcpiGbl_CreateOsiMethod; -extern UINT8 AcpiGbl_LeaveWakeGpesDisabled; +extern UINT8 AcpiGbl_UseDefaultRegisterWidths; extern ACPI_NAME AcpiGbl_TraceMethodName; extern UINT32 AcpiGbl_TraceFlags; +extern UINT8 AcpiGbl_EnableAmlDebugObject; +extern UINT8 AcpiGbl_CopyDsdtLocally; +extern UINT8 AcpiGbl_TruncateIoAddresses; /* - * Global interfaces + * Initialization */ ACPI_STATUS AcpiInitializeTables ( @@ -168,10 +175,10 @@ ACPI_STATUS AcpiTerminate ( void); -ACPI_STATUS -AcpiSubsystemStatus ( - void); +/* + * Miscellaneous global interfaces + */ ACPI_STATUS AcpiEnable ( void); @@ -180,6 +187,10 @@ ACPI_STATUS AcpiDisable ( void); +ACPI_STATUS +AcpiSubsystemStatus ( + void); + ACPI_STATUS AcpiGetSystemInfo ( ACPI_BUFFER *RetBuffer); @@ -196,9 +207,17 @@ ACPI_STATUS AcpiPurgeCachedObjects ( void); +ACPI_STATUS +AcpiInstallInterface ( + ACPI_STRING InterfaceName); + +ACPI_STATUS +AcpiRemoveInterface ( + ACPI_STRING InterfaceName); + /* - * ACPI Memory managment + * ACPI Memory management */ void * AcpiAllocate ( @@ -263,7 +282,8 @@ AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, - ACPI_WALK_CALLBACK UserFunction, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, void *Context, void **ReturnValue); @@ -276,7 +296,7 @@ AcpiGetDevices ( ACPI_STATUS AcpiGetName ( - ACPI_HANDLE Handle, + ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr); @@ -288,18 +308,18 @@ AcpiGetHandle ( ACPI_STATUS AcpiAttachData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, void *Data); ACPI_STATUS AcpiDetachData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler); ACPI_STATUS AcpiGetData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, void **Data); @@ -331,8 +351,8 @@ AcpiEvaluateObjectTyped ( ACPI_STATUS AcpiGetObjectInfo ( - ACPI_HANDLE Handle, - ACPI_BUFFER *ReturnBuffer); + ACPI_HANDLE Object, + ACPI_DEVICE_INFO **ReturnBuffer); ACPI_STATUS AcpiInstallMethod ( @@ -364,6 +384,11 @@ AcpiInstallInitializationHandler ( ACPI_INIT_HANDLER Handler, UINT32 Function); +ACPI_STATUS +AcpiInstallGlobalEventHandler ( + ACPI_GBL_EVENT_HANDLER Handler, + void *Context); + ACPI_STATUS AcpiInstallFixedEventHandler ( UINT32 AcpiEvent, @@ -375,6 +400,20 @@ AcpiRemoveFixedEventHandler ( UINT32 AcpiEvent, ACPI_EVENT_HANDLER Handler); +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_GPE_HANDLER Address, + void *Context); + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_GPE_HANDLER Address); + ACPI_STATUS AcpiInstallNotifyHandler ( ACPI_HANDLE Device, @@ -402,27 +441,17 @@ AcpiRemoveAddressSpaceHandler ( ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler); -ACPI_STATUS -AcpiInstallGpeHandler ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Type, - ACPI_EVENT_HANDLER Address, - void *Context); - -ACPI_STATUS -AcpiRemoveGpeHandler ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - ACPI_EVENT_HANDLER Address); - ACPI_STATUS AcpiInstallExceptionHandler ( ACPI_EXCEPTION_HANDLER Handler); +ACPI_STATUS +AcpiInstallInterfaceHandler ( + ACPI_INTERFACE_HANDLER Handler); + /* - * Event interfaces + * Global Lock interfaces */ ACPI_STATUS AcpiAcquireGlobalLock ( @@ -433,6 +462,10 @@ ACPI_STATUS AcpiReleaseGlobalLock ( UINT32 Handle); + +/* + * Fixed Event interfaces + */ ACPI_STATUS AcpiEnableEvent ( UINT32 Event, @@ -454,37 +487,54 @@ AcpiGetEventStatus ( /* - * GPE Interfaces + * General Purpose Event (GPE) Interfaces */ ACPI_STATUS -AcpiSetGpeType ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT8 Type); +AcpiUpdateAllGpes ( + void); ACPI_STATUS AcpiEnableGpe ( ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags); + UINT32 GpeNumber); ACPI_STATUS AcpiDisableGpe ( ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags); + UINT32 GpeNumber); ACPI_STATUS AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + +ACPI_STATUS +AcpiSetGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - UINT32 Flags); + UINT8 Action); + +ACPI_STATUS +AcpiFinishGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + +ACPI_STATUS +AcpiSetupGpeForWake ( + ACPI_HANDLE ParentDevice, + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + +ACPI_STATUS +AcpiSetGpeWakeMask ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Action); ACPI_STATUS AcpiGetGpeStatus ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - UINT32 Flags, ACPI_EVENT_STATUS *EventStatus); ACPI_STATUS @@ -522,36 +572,36 @@ ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( ACPI_STATUS AcpiGetVendorResource ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, char *Name, ACPI_VENDOR_UUID *Uuid, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiGetCurrentResources( - ACPI_HANDLE DeviceHandle, +AcpiGetCurrentResources ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiGetPossibleResources( - ACPI_HANDLE DeviceHandle, +AcpiGetPossibleResources ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS AcpiWalkResources ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, char *Name, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context); ACPI_STATUS AcpiSetCurrentResources ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, ACPI_BUFFER *InBuffer); ACPI_STATUS -AcpiGetIrqRoutingTable ( - ACPI_HANDLE BusDeviceHandle, +AcpiGetIrqRoutingTable ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS @@ -569,12 +619,12 @@ AcpiReset ( ACPI_STATUS AcpiRead ( - UINT32 *Value, + UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg); ACPI_STATUS AcpiWrite ( - UINT32 Value, + UINT64 Value, ACPI_GENERIC_ADDRESS *Reg); ACPI_STATUS diff --git a/sys/contrib/dev/acpica-unix/include/acpredef.h b/sys/contrib/dev/acpica-unix/include/acpredef.h index 9e5a5247e7..922e2ca332 100644 --- a/sys/contrib/dev/acpica-unix/include/acpredef.h +++ b/sys/contrib/dev/acpica-unix/include/acpredef.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -136,8 +136,8 @@ * (Used for _PRW) * * - * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each of the - * different types describe the contents of each of the sub-packages. + * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each + * of the different types describe the contents of each of the sub-packages. * * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: * object type @@ -157,12 +157,15 @@ * count * (Used for _CST) * - * ACPI_PTYPE2_Fixed-length: Each subpackage is of Fixed-length length + * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length * (Used for _PRT) * * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length * (Used for _HPX) * + * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length + * (Used for _ART, _FPS) + * *****************************************************************************/ enum AcpiReturnPackageTypes @@ -174,10 +177,12 @@ enum AcpiReturnPackageTypes ACPI_PTYPE2_COUNT = 5, ACPI_PTYPE2_PKG_COUNT = 6, ACPI_PTYPE2_FIXED = 7, - ACPI_PTYPE2_MIN = 8 + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9 }; +#ifdef ACPI_CREATE_PREDEFINED_TABLE /* * Predefined method/object information table. * @@ -188,7 +193,7 @@ enum AcpiReturnPackageTypes * AcpiEvaluateObject: * _Lxx and _Exx GPE methods * _Qxx EC methods - * _T_x compiler temporary Variable-lengths + * _T_x compiler temporary variables * * 2) Predefined names that never actually exist within the AML code: * Predefined resource descriptor field names @@ -263,21 +268,30 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, {{"_ALT", 0, ACPI_RTYPE_INTEGER}}, + {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 11,0}}, + {{"_BBN", 0, ACPI_RTYPE_INTEGER}}, {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, {{"_BCM", 1, 0}}, + {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, {{"_BFS", 1, 0}}, {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */ {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4,0}}, + {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,0}}, + {{"_BLT", 3, 0}}, + {{"_BMA", 1, ACPI_RTYPE_INTEGER}}, {{"_BMC", 1, 0}}, {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */ {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + {{"_BMS", 1, ACPI_RTYPE_INTEGER}}, {{"_BQC", 0, ACPI_RTYPE_INTEGER}}, {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, @@ -285,6 +299,7 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_BTM", 1, ACPI_RTYPE_INTEGER}}, {{"_BTP", 1, 0}}, {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ + {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, @@ -310,6 +325,7 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ {{"_DSS", 1, 0}}, {{"_DSW", 3, 0}}, + {{"_DTI", 1, 0}}, {{"_EC_", 0, ACPI_RTYPE_INTEGER}}, {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, @@ -325,9 +341,22 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, {{"_FDM", 1, 0}}, + {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_INTEGER, 5, 0}, 0,0}}, + + {{"_FSL", 1, 0}}, + {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0}, 0,0}}, + + + {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, + {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ @@ -355,15 +384,21 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_LCK", 1, 0}}, {{"_LID", 0, ACPI_RTYPE_INTEGER}}, {{"_MAT", 0, ACPI_RTYPE_BUFFER}}, + {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8,0}, 0,0}}, + {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */ {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}}, {{"_MSG", 1, 0}}, + {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, + {{"_NTT", 0, ACPI_RTYPE_INTEGER}}, {{"_OFF", 0, 0}}, {{"_ON_", 0, 0}}, {{"_OS_", 0, ACPI_RTYPE_STRING}}, {{"_OSC", 4, ACPI_RTYPE_BUFFER}}, {{"_OST", 3, 0}}, + {{"_PAI", 1, ACPI_RTYPE_INTEGER}}, {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, @@ -371,10 +406,21 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, {{"_PDC", 1, 0}}, + {{"_PDL", 0, ACPI_RTYPE_INTEGER}}, {{"_PIC", 1, 0}}, + {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3,0}}, + {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}}, + {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PMM", 0, ACPI_RTYPE_INTEGER}}, {{"_PPC", 0, ACPI_RTYPE_INTEGER}}, {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */ {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ @@ -386,17 +432,26 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + {{"_PRS", 0, ACPI_RTYPE_BUFFER}}, /* - * For _PRT, many BIOSs reverse the 2nd and 3rd Package elements. This bug is so prevalent that there - * is code in the ACPICA Resource Manager to detect this and switch them back. For now, do not allow - * and issue a warning. To allow this and eliminate the warning, add the ACPI_RTYPE_REFERENCE - * type to the 2nd element (index 1) in the statement below. + * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source + * and SourceIndex). This bug is so prevalent that there is code in the + * ACPICA Resource Manager to detect this and switch them back. For now, + * do not allow and issue a warning. To allow this and eliminate the + * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) + * in the statement below. */ {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER}, - ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE,ACPI_RTYPE_INTEGER}}, + ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, + ACPI_RTYPE_INTEGER}}, {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, @@ -422,7 +477,11 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + {{"_PTP", 2, ACPI_RTYPE_INTEGER}}, {{"_PTS", 1, 0}}, + {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + {{"_PXM", 0, ACPI_RTYPE_INTEGER}}, {{"_REG", 2, 0}}, {{"_REV", 0, ACPI_RTYPE_INTEGER}}, @@ -468,6 +527,7 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = /* Note: the 3-arg definition may be removed for ACPI 4.0 */ {{"_SDD", 1, 0}}, {{"_SEG", 0, ACPI_RTYPE_INTEGER}}, + {{"_SHL", 1, ACPI_RTYPE_INTEGER}}, {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, {{"_SRS", 1, 0}}, @@ -475,11 +535,15 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_SST", 1, 0}}, {{"_STA", 0, ACPI_RTYPE_INTEGER}}, {{"_STM", 3, 0}}, + {{"_STP", 2, ACPI_RTYPE_INTEGER}}, {{"_STR", 0, ACPI_RTYPE_BUFFER}}, + {{"_STV", 2, ACPI_RTYPE_INTEGER}}, {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, + {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, {{"_TPT", 1, 0}}, @@ -513,14 +577,15 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ + /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ + + {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, + {{"_WED", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER}}, + {{{0,0,0,0}, 0,0}} /* Table terminator */ }; #if 0 - /* Not implemented */ - - {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */ - {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */ /* This is an internally implemented control method, no need to check */ {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, @@ -530,5 +595,5 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = _PRT - currently ignore reversed entries. Attempt to fix here? Think about possibly fixing package elements like _BIF, etc. #endif - +#endif #endif diff --git a/sys/contrib/dev/acpica-unix/include/acresrc.h b/sys/contrib/dev/acpica-unix/include/acresrc.h index c70aa5e23d..05ff90c0c1 100644 --- a/sys/contrib/dev/acpica-unix/include/acresrc.h +++ b/sys/contrib/dev/acpica-unix/include/acresrc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/acrestyp.h b/sys/contrib/dev/acpica-unix/include/acrestyp.h index 7eb7600d98..d85e4a9b30 100644 --- a/sys/contrib/dev/acpica-unix/include/acrestyp.h +++ b/sys/contrib/dev/acpica-unix/include/acrestyp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -534,7 +534,7 @@ typedef struct acpi_pci_routing_table { UINT32 Length; UINT32 Pin; - ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT64 Address; /* here for 64-bit alignment */ UINT32 SourceIndex; char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ diff --git a/sys/contrib/dev/acpica-unix/include/acstruct.h b/sys/contrib/dev/acpica-unix/include/acstruct.h index 45c85fe0b2..e90d8ecedf 100644 --- a/sys/contrib/dev/acpica-unix/include/acstruct.h +++ b/sys/contrib/dev/acpica-unix/include/acstruct.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -204,23 +204,23 @@ typedef struct acpi_walk_state } ACPI_WALK_STATE; -/* Info used by AcpiPsInitObjects */ +/* Info used by AcpiNsInitializeObjects and AcpiDsInitializeObjects */ typedef struct acpi_init_walk_info { - UINT16 MethodCount; - UINT16 DeviceCount; - UINT16 OpRegionCount; - UINT16 FieldCount; - UINT16 BufferCount; - UINT16 PackageCount; - UINT16 OpRegionInit; - UINT16 FieldInit; - UINT16 BufferInit; - UINT16 PackageInit; - UINT16 ObjectCount; - ACPI_OWNER_ID OwnerId; UINT32 TableIndex; + UINT32 ObjectCount; + UINT32 MethodCount; + UINT32 DeviceCount; + UINT32 OpRegionCount; + UINT32 FieldCount; + UINT32 BufferCount; + UINT32 PackageCount; + UINT32 OpRegionInit; + UINT32 FieldInit; + UINT32 BufferInit; + UINT32 PackageInit; + ACPI_OWNER_ID OwnerId; } ACPI_INIT_WALK_INFO; @@ -294,11 +294,11 @@ typedef struct acpi_evaluate_info typedef struct acpi_device_walk_info { - UINT16 DeviceCount; - UINT16 Num_STA; - UINT16 Num_INI; ACPI_TABLE_DESC *TableDesc; ACPI_EVALUATE_INFO *EvaluateInfo; + UINT32 DeviceCount; + UINT32 Num_STA; + UINT32 Num_INI; } ACPI_DEVICE_WALK_INFO; diff --git a/sys/contrib/dev/acpica-unix/include/actables.h b/sys/contrib/dev/acpica-unix/include/actables.h index e4428e6415..d19e6845d7 100644 --- a/sys/contrib/dev/acpica-unix/include/actables.h +++ b/sys/contrib/dev/acpica-unix/include/actables.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -230,6 +230,14 @@ AcpiTbVerifyChecksum ( ACPI_TABLE_HEADER *Table, UINT32 Length); +void +AcpiTbCheckDsdtHeader ( + void); + +ACPI_TABLE_HEADER * +AcpiTbCopyDsdt ( + UINT32 TableIndex); + void AcpiTbInstallTable ( ACPI_PHYSICAL_ADDRESS Address, diff --git a/sys/contrib/dev/acpica-unix/include/actbl.h b/sys/contrib/dev/acpica-unix/include/actbl.h index 9d53404d60..3cec93028f 100644 --- a/sys/contrib/dev/acpica-unix/include/actbl.h +++ b/sys/contrib/dev/acpica-unix/include/actbl.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,9 +116,25 @@ #ifndef __ACTBL_H__ #define __ACTBL_H__ + +/******************************************************************************* + * + * Fundamental ACPI tables + * + * This file contains definitions for the ACPI tables that are directly consumed + * by ACPICA. All other tables are consumed by the OS-dependent ACPI-related + * device drivers and other OS support code. + * + * The RSDP and FACS do not use the common ACPI table header. All other ACPI + * tables use the header. + * + ******************************************************************************/ + + /* - * Values for description table header signatures. Useful because they make - * it more difficult to inadvertently type in the wrong signature. + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. */ #define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ #define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ @@ -137,23 +153,17 @@ */ #pragma pack(1) - /* - * These are the ACPI tables that are directly consumed by the subsystem. - * - * The RSDP and FACS do not use the common ACPI table header. All other ACPI - * tables use the header. - * * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. * This is the only type that is even remotely portable. Anything else is not * portable, so do not use any other bitfield types. */ + /******************************************************************************* * - * ACPI Table Header. This common header is used by all tables except the - * RSDP and FACS. The define is used for direct inclusion of header into - * other ACPI tables + * Master ACPI Table Header. This common header is used by all ACPI tables + * except the RSDP and FACS. * ******************************************************************************/ @@ -172,13 +182,16 @@ typedef struct acpi_table_header } ACPI_TABLE_HEADER; -/* +/******************************************************************************* + * * GAS - Generic Address Structure (ACPI 2.0+) * * Note: Since this structure is used in the ACPI tables, it is byte aligned. - * If misalignment is not supported, access to the Address field must be - * performed with care. - */ + * If misaliged access is not supported by the hardware, accesses to the + * 64-bit Address field must be performed with care. + * + ******************************************************************************/ + typedef struct acpi_generic_address { UINT8 SpaceId; /* Address space where struct or register exists */ @@ -193,6 +206,7 @@ typedef struct acpi_generic_address /******************************************************************************* * * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * Version 2 * ******************************************************************************/ @@ -210,12 +224,34 @@ typedef struct acpi_table_rsdp } ACPI_TABLE_RSDP; -#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ +/* Standalone struct for the ACPI 1.0 RSDP */ + +typedef struct acpi_rsdp_common +{ + char Signature[8]; + UINT8 Checksum; + char OemId[ACPI_OEM_ID_SIZE]; + UINT8 Revision; + UINT32 RsdtPhysicalAddress; + +} ACPI_RSDP_COMMON; + +/* Standalone struct for the extended part of the RSDP (ACPI 2.0+) */ + +typedef struct acpi_rsdp_extension +{ + UINT32 Length; + UINT64 XsdtPhysicalAddress; + UINT8 ExtendedChecksum; + UINT8 Reserved[3]; + +} ACPI_RSDP_EXTENSION; /******************************************************************************* * * RSDT/XSDT - Root System Description Tables + * Version 1 (both) * ******************************************************************************/ @@ -250,23 +286,31 @@ typedef struct acpi_table_facs UINT32 Flags; UINT64 XFirmwareWakingVector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ UINT8 Version; /* Version of this table (ACPI 2.0+) */ - UINT8 Reserved[31]; /* Reserved, must be zero */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 OspmFlags; /* Flags to be set by OSPM (ACPI 4.0) */ + UINT8 Reserved1[24]; /* Reserved, must be zero */ } ACPI_TABLE_FACS; -/* Flag macros */ +/* Masks for GlobalLock flag field above */ + +#define ACPI_GLOCK_PENDING (1) /* 00: Pending global lock ownership */ +#define ACPI_GLOCK_OWNED (1<<1) /* 01: Global lock is owned */ -#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +/* Masks for Flags field above */ -/* Global lock flags */ +#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +#define ACPI_FACS_64BIT_WAKE (1<<1) /* 01: 64-bit wake vector supported (ACPI 4.0) */ -#define ACPI_GLOCK_PENDING 0x01 /* 00: Pending global lock ownership */ -#define ACPI_GLOCK_OWNED 0x02 /* 01: Global lock is owned */ +/* Masks for OspmFlags field above */ + +#define ACPI_FACS_64BIT_ENVIRONMENT (1) /* 00: 64-bit wake environment is required (ACPI 4.0) */ /******************************************************************************* * * FADT - Fixed ACPI Description Table (Signature "FACP") + * Version 4 * ******************************************************************************/ @@ -330,7 +374,7 @@ typedef struct acpi_table_fadt } ACPI_TABLE_FADT; -/* FADT Boot Architecture Flags (BootFlags) */ +/* Masks for FADT Boot Architecture Flags (BootFlags) */ #define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ #define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ @@ -338,7 +382,7 @@ typedef struct acpi_table_fadt #define ACPI_FADT_NO_MSI (1<<3) /* 03: [V4] Message Signaled Interrupts (MSI) must not be enabled */ #define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ -/* FADT flags */ +/* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1) /* 00: [V1] The wbinvd instruction works properly */ #define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] wbinvd flushes but does not invalidate caches */ @@ -362,7 +406,7 @@ typedef struct acpi_table_fadt #define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local xAPICs must use physical dest mode (ACPI 3.0) */ -/* FADT Prefered Power Management Profiles */ +/* Values for PreferredProfile (Prefered Power Management Profiles) */ enum AcpiPreferedPmProfiles { @@ -381,6 +425,9 @@ enum AcpiPreferedPmProfiles #pragma pack() +/* + * Internal table-related structures + */ typedef union acpi_name_union { UINT32 Integer; @@ -388,9 +435,9 @@ typedef union acpi_name_union } ACPI_NAME_UNION; -/* - * Internal ACPI Table Descriptor. One per ACPI table - */ + +/* Internal ACPI Table Descriptor. One per ACPI table. */ + typedef struct acpi_table_desc { ACPI_PHYSICAL_ADDRESS Address; @@ -402,7 +449,7 @@ typedef struct acpi_table_desc } ACPI_TABLE_DESC; -/* Flags for above */ +/* Masks for Flags field above */ #define ACPI_TABLE_ORIGIN_UNKNOWN (0) #define ACPI_TABLE_ORIGIN_MAPPED (1) @@ -416,9 +463,26 @@ typedef struct acpi_table_desc * Get the remaining ACPI tables */ #include "actbl1.h" +#include "actbl2.h" /* Macros used to generate offsets to specific table fields */ #define ACPI_FADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_FADT, f) +/* + * Sizes of the various flavors of FADT. We need to look closely + * at the FADT length because the version number essentially tells + * us nothing because of many BIOS bugs where the version does not + * match the expected length. In other words, the length of the + * FADT is the bottom line as to what the version really is. + * + * For reference, the values below are as follows: + * FADT V1 size: 0x74 + * FADT V2 size: 0x84 + * FADT V3+ size: 0xF4 + */ +#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (Reserved4[0]) + 3) +#define ACPI_FADT_V3_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) + #endif /* __ACTBL_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/actbl1.h b/sys/contrib/dev/acpica-unix/include/actbl1.h index dc5519b622..a593f44170 100644 --- a/sys/contrib/dev/acpica-unix/include/actbl1.h +++ b/sys/contrib/dev/acpica-unix/include/actbl1.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,42 +119,32 @@ /******************************************************************************* * - * Additional ACPI Tables + * Additional ACPI Tables (1) * * These tables are not consumed directly by the ACPICA subsystem, but are * included here to support device drivers and the AML disassembler. * + * The tables in this file are fully defined within the ACPI specification. + * ******************************************************************************/ /* - * Values for description table header signatures. Useful because they make - * it more difficult to inadvertently type in the wrong signature. + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. */ -#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ -#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ #define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ -#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ -#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ #define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ #define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ #define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ #define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ -#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ -#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ #define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ -#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ #define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ -#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ #define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ -#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ -#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ #define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ -#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ -#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ -#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ -#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ /* @@ -170,7 +160,13 @@ */ -/* Common Subtable header (used in MADT, SRAT, etc.) */ +/******************************************************************************* + * + * Common subtable headers + * + ******************************************************************************/ + +/* Generic subtable header (used in MADT, SRAT, etc.) */ typedef struct acpi_subtable_header { @@ -180,7 +176,7 @@ typedef struct acpi_subtable_header } ACPI_SUBTABLE_HEADER; -/* Common Subtable header for WHEA tables (EINJ, ERST, WDAT) */ +/* Subtable header for WHEA tables (EINJ, ERST, WDAT) */ typedef struct acpi_whea_header { @@ -197,138 +193,8 @@ typedef struct acpi_whea_header /******************************************************************************* * - * ASF - Alert Standard Format table (Signature "ASF!") - * - * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 - * - ******************************************************************************/ - -typedef struct acpi_table_asf -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - -} ACPI_TABLE_ASF; - - -/* ASF subtable header */ - -typedef struct acpi_asf_header -{ - UINT8 Type; - UINT8 Reserved; - UINT16 Length; - -} ACPI_ASF_HEADER; - - -/* Values for Type field above */ - -enum AcpiAsfType -{ - ACPI_ASF_TYPE_INFO = 0, - ACPI_ASF_TYPE_ALERT = 1, - ACPI_ASF_TYPE_CONTROL = 2, - ACPI_ASF_TYPE_BOOT = 3, - ACPI_ASF_TYPE_ADDRESS = 4, - ACPI_ASF_TYPE_RESERVED = 5 -}; - -/* - * ASF subtables - */ - -/* 0: ASF Information */ - -typedef struct acpi_asf_info -{ - ACPI_ASF_HEADER Header; - UINT8 MinResetValue; - UINT8 MinPollInterval; - UINT16 SystemId; - UINT32 MfgId; - UINT8 Flags; - UINT8 Reserved2[3]; - -} ACPI_ASF_INFO; - -/* 1: ASF Alerts */ - -typedef struct acpi_asf_alert -{ - ACPI_ASF_HEADER Header; - UINT8 AssertMask; - UINT8 DeassertMask; - UINT8 Alerts; - UINT8 DataLength; - -} ACPI_ASF_ALERT; - -typedef struct acpi_asf_alert_data -{ - UINT8 Address; - UINT8 Command; - UINT8 Mask; - UINT8 Value; - UINT8 SensorType; - UINT8 Type; - UINT8 Offset; - UINT8 SourceType; - UINT8 Severity; - UINT8 SensorNumber; - UINT8 Entity; - UINT8 Instance; - -} ACPI_ASF_ALERT_DATA; - -/* 2: ASF Remote Control */ - -typedef struct acpi_asf_remote -{ - ACPI_ASF_HEADER Header; - UINT8 Controls; - UINT8 DataLength; - UINT16 Reserved2; - -} ACPI_ASF_REMOTE; - -typedef struct acpi_asf_control_data -{ - UINT8 Function; - UINT8 Address; - UINT8 Command; - UINT8 Value; - -} ACPI_ASF_CONTROL_DATA; - -/* 3: ASF RMCP Boot Options */ - -typedef struct acpi_asf_rmcp -{ - ACPI_ASF_HEADER Header; - UINT8 Capabilities[7]; - UINT8 CompletionCode; - UINT32 EnterpriseId; - UINT8 Command; - UINT16 Parameter; - UINT16 BootOptions; - UINT16 OemParameters; - -} ACPI_ASF_RMCP; - -/* 4: ASF Address */ - -typedef struct acpi_asf_address -{ - ACPI_ASF_HEADER Header; - UINT8 EpromAddress; - UINT8 Devices; - -} ACPI_ASF_ADDRESS; - - -/******************************************************************************* - * - * BERT - Boot Error Record Table + * BERT - Boot Error Record Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -341,44 +207,47 @@ typedef struct acpi_table_bert } ACPI_TABLE_BERT; -/* Boot Error Region */ +/* Boot Error Region (not a subtable, pointed to by Address field above) */ typedef struct acpi_bert_region { - UINT32 BlockStatus; - UINT32 RawDataOffset; - UINT32 RawDataLength; - UINT32 DataLength; - UINT32 ErrorSeverity; + UINT32 BlockStatus; /* Type of error information */ + UINT32 RawDataOffset; /* Offset to raw error data */ + UINT32 RawDataLength; /* Length of raw error data */ + UINT32 DataLength; /* Length of generic error data */ + UINT32 ErrorSeverity; /* Severity code */ } ACPI_BERT_REGION; -/* BlockStatus Flags */ +/* Values for BlockStatus flags above */ #define ACPI_BERT_UNCORRECTABLE (1) -#define ACPI_BERT_CORRECTABLE (2) -#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (4) -#define ACPI_BERT_MULTIPLE_CORRECTABLE (8) - +#define ACPI_BERT_CORRECTABLE (1<<1) +#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_BERT_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_BERT_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ -/******************************************************************************* - * - * BOOT - Simple Boot Flag Table - * - ******************************************************************************/ +/* Values for ErrorSeverity above */ -typedef struct acpi_table_boot +enum AcpiBertErrorSeverity { - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ - UINT8 Reserved[3]; + ACPI_BERT_ERROR_CORRECTABLE = 0, + ACPI_BERT_ERROR_FATAL = 1, + ACPI_BERT_ERROR_CORRECTED = 2, + ACPI_BERT_ERROR_NONE = 3, + ACPI_BERT_ERROR_RESERVED = 4 /* 4 and greater are reserved */ +}; -} ACPI_TABLE_BOOT; +/* + * Note: The generic error data that follows the ErrorSeverity field above + * uses the ACPI_HEST_GENERIC_DATA defined under the HEST table below + */ /******************************************************************************* * - * CPEP - Corrected Platform Error Polling table + * CPEP - Corrected Platform Error Polling table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -394,8 +263,7 @@ typedef struct acpi_table_cpep typedef struct acpi_cpep_polling { - UINT8 Type; - UINT8 Length; + ACPI_SUBTABLE_HEADER Header; UINT8 Id; /* Processor ID */ UINT8 Eid; /* Processor EID */ UINT32 Interval; /* Polling interval (msec) */ @@ -403,145 +271,10 @@ typedef struct acpi_cpep_polling } ACPI_CPEP_POLLING; -/******************************************************************************* - * - * DBGP - Debug Port table - * - ******************************************************************************/ - -typedef struct acpi_table_dbgp -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ - UINT8 Reserved[3]; - ACPI_GENERIC_ADDRESS DebugPort; - -} ACPI_TABLE_DBGP; - - -/******************************************************************************* - * - * DMAR - DMA Remapping table - * From "Intel Virtualization Technology for Directed I/O", Sept. 2007 - * - ******************************************************************************/ - -typedef struct acpi_table_dmar -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Width; /* Host Address Width */ - UINT8 Flags; - UINT8 Reserved[10]; - -} ACPI_TABLE_DMAR; - -/* Flags */ - -#define ACPI_DMAR_INTR_REMAP (1) - -/* DMAR subtable header */ - -typedef struct acpi_dmar_header -{ - UINT16 Type; - UINT16 Length; - -} ACPI_DMAR_HEADER; - -/* Values for subtable type in ACPI_DMAR_HEADER */ - -enum AcpiDmarType -{ - ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, - ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, - ACPI_DMAR_TYPE_ATSR = 2, - ACPI_DMAR_TYPE_RESERVED = 3 /* 3 and greater are reserved */ -}; - -typedef struct acpi_dmar_device_scope -{ - UINT8 EntryType; - UINT8 Length; - UINT16 Reserved; - UINT8 EnumerationId; - UINT8 Bus; - -} ACPI_DMAR_DEVICE_SCOPE; - -/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ - -enum AcpiDmarScopeType -{ - ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, - ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, - ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, - ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, - ACPI_DMAR_SCOPE_TYPE_HPET = 4, - ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ -}; - -typedef struct acpi_dmar_pci_path -{ - UINT8 Device; - UINT8 Function; - -} ACPI_DMAR_PCI_PATH; - -/* - * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER - */ - -/* 0: Hardware Unit Definition */ - -typedef struct acpi_dmar_hardware_unit -{ - ACPI_DMAR_HEADER Header; - UINT8 Flags; - UINT8 Reserved; - UINT16 Segment; - UINT64 Address; /* Register Base Address */ - -} ACPI_DMAR_HARDWARE_UNIT; - -/* Flags */ - -#define ACPI_DMAR_INCLUDE_ALL (1) - -/* 1: Reserved Memory Defininition */ - -typedef struct acpi_dmar_reserved_memory -{ - ACPI_DMAR_HEADER Header; - UINT16 Reserved; - UINT16 Segment; - UINT64 BaseAddress; /* 4K aligned base address */ - UINT64 EndAddress; /* 4K aligned limit address */ - -} ACPI_DMAR_RESERVED_MEMORY; - -/* Flags */ - -#define ACPI_DMAR_ALLOW_ALL (1) - -/* 2: Root Port ATS Capability Reporting Structure */ - -typedef struct acpi_dmar_atsr -{ - ACPI_DMAR_HEADER Header; - UINT8 Flags; - UINT8 Reserved; - UINT16 Segment; - -} ACPI_DMAR_ATSR; - -/* Flags */ - -#define ACPI_DMAR_ALL_PORTS (1) - - /******************************************************************************* * * ECDT - Embedded Controller Boot Resources Table + * Version 1 * ******************************************************************************/ @@ -559,7 +292,8 @@ typedef struct acpi_table_ecdt /******************************************************************************* * - * EINJ - Error Injection Table + * EINJ - Error Injection Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -567,11 +301,13 @@ typedef struct acpi_table_einj { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ UINT32 HeaderLength; - UINT32 Reserved; + UINT8 Flags; + UINT8 Reserved[3]; UINT32 Entries; } ACPI_TABLE_EINJ; + /* EINJ Injection Instruction Entries (actions) */ typedef struct acpi_einj_entry @@ -580,6 +316,10 @@ typedef struct acpi_einj_entry } ACPI_EINJ_ENTRY; +/* Masks for Flags field above */ + +#define ACPI_EINJ_PRESERVE (1) + /* Values for Action field above */ enum AcpiEinjActions @@ -608,6 +348,7 @@ enum AcpiEinjInstructions ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */ }; + /* EINJ Trigger Error Action Table */ typedef struct acpi_einj_trigger @@ -619,10 +360,37 @@ typedef struct acpi_einj_trigger } ACPI_EINJ_TRIGGER; +/* Command status return values */ + +enum AcpiEinjCommandStatus +{ + ACPI_EINJ_SUCCESS = 0, + ACPI_EINJ_FAILURE = 1, + ACPI_EINJ_INVALID_ACCESS = 2, + ACPI_EINJ_STATUS_RESERVED = 3 /* 3 and greater are reserved */ +}; + + +/* Error types returned from ACPI_EINJ_GET_ERROR_TYPE (bitfield) */ + +#define ACPI_EINJ_PROCESSOR_CORRECTABLE (1) +#define ACPI_EINJ_PROCESSOR_UNCORRECTABLE (1<<1) +#define ACPI_EINJ_PROCESSOR_FATAL (1<<2) +#define ACPI_EINJ_MEMORY_CORRECTABLE (1<<3) +#define ACPI_EINJ_MEMORY_UNCORRECTABLE (1<<4) +#define ACPI_EINJ_MEMORY_FATAL (1<<5) +#define ACPI_EINJ_PCIX_CORRECTABLE (1<<6) +#define ACPI_EINJ_PCIX_UNCORRECTABLE (1<<7) +#define ACPI_EINJ_PCIX_FATAL (1<<8) +#define ACPI_EINJ_PLATFORM_CORRECTABLE (1<<9) +#define ACPI_EINJ_PLATFORM_UNCORRECTABLE (1<<10) +#define ACPI_EINJ_PLATFORM_FATAL (1<<11) + /******************************************************************************* * - * ERST - Error Record Serialization Table + * ERST - Error Record Serialization Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -635,6 +403,7 @@ typedef struct acpi_table_erst } ACPI_TABLE_ERST; + /* ERST Serialization Entries (actions) */ typedef struct acpi_erst_entry @@ -643,20 +412,24 @@ typedef struct acpi_erst_entry } ACPI_ERST_ENTRY; +/* Masks for Flags field above */ + +#define ACPI_ERST_PRESERVE (1) + /* Values for Action field above */ enum AcpiErstActions { - ACPI_ERST_BEGIN_WRITE_OPERATION = 0, - ACPI_ERST_BEGIN_READ_OPERATION = 1, - ACPI_ERST_BETGIN_CLEAR_OPERATION= 2, - ACPI_ERST_END_OPERATION = 3, + ACPI_ERST_BEGIN_WRITE = 0, + ACPI_ERST_BEGIN_READ = 1, + ACPI_ERST_BEGIN_CLEAR = 2, + ACPI_ERST_END = 3, ACPI_ERST_SET_RECORD_OFFSET = 4, ACPI_ERST_EXECUTE_OPERATION = 5, ACPI_ERST_CHECK_BUSY_STATUS = 6, ACPI_ERST_GET_COMMAND_STATUS = 7, - ACPI_ERST_GET_RECORD_IDENTIFIER = 8, - ACPI_ERST_SET_RECORD_IDENTIFIER = 9, + ACPI_ERST_GET_RECORD_ID = 8, + ACPI_ERST_SET_RECORD_ID = 9, ACPI_ERST_GET_RECORD_COUNT = 10, ACPI_ERST_BEGIN_DUMMY_WRIITE = 11, ACPI_ERST_NOT_USED = 12, @@ -692,10 +465,34 @@ enum AcpiErstInstructions ACPI_ERST_INSTRUCTION_RESERVED = 19 /* 19 and greater are reserved */ }; +/* Command status return values */ + +enum AcpiErstCommandStatus +{ + ACPI_ERST_SUCESS = 0, + ACPI_ERST_NO_SPACE = 1, + ACPI_ERST_NOT_AVAILABLE = 2, + ACPI_ERST_FAILURE = 3, + ACPI_ERST_RECORD_EMPTY = 4, + ACPI_ERST_NOT_FOUND = 5, + ACPI_ERST_STATUS_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* Error Record Serialization Information */ + +typedef struct acpi_erst_info +{ + UINT16 Signature; /* Should be "ER" */ + UINT8 Data[48]; + +} ACPI_ERST_INFO; + /******************************************************************************* * - * HEST - Hardware Error Source Table + * HEST - Hardware Error Source Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ @@ -712,6 +509,7 @@ typedef struct acpi_table_hest typedef struct acpi_hest_header { UINT16 Type; + UINT16 SourceId; } ACPI_HEST_HEADER; @@ -720,92 +518,69 @@ typedef struct acpi_hest_header enum AcpiHestTypes { - ACPI_HEST_TYPE_XPF_MACHINE_CHECK = 0, - ACPI_HEST_TYPE_XPF_CORRECTED_MACHINE_CHECK = 1, - ACPI_HEST_TYPE_XPF_UNUSED = 2, - ACPI_HEST_TYPE_XPF_NON_MASKABLE_INTERRUPT = 3, - ACPI_HEST_TYPE_IPF_CORRECTED_MACHINE_CHECK = 4, - ACPI_HEST_TYPE_IPF_CORRECTED_PLATFORM_ERROR = 5, - ACPI_HEST_TYPE_AER_ROOT_PORT = 6, - ACPI_HEST_TYPE_AER_ENDPOINT = 7, - ACPI_HEST_TYPE_AER_BRIDGE = 8, - ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE = 9, - ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ + ACPI_HEST_TYPE_IA32_CHECK = 0, + ACPI_HEST_TYPE_IA32_CORRECTED_CHECK = 1, + ACPI_HEST_TYPE_IA32_NMI = 2, + ACPI_HEST_TYPE_NOT_USED3 = 3, + ACPI_HEST_TYPE_NOT_USED4 = 4, + ACPI_HEST_TYPE_NOT_USED5 = 5, + ACPI_HEST_TYPE_AER_ROOT_PORT = 6, + ACPI_HEST_TYPE_AER_ENDPOINT = 7, + ACPI_HEST_TYPE_AER_BRIDGE = 8, + ACPI_HEST_TYPE_GENERIC_ERROR = 9, + ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ }; /* - * HEST Sub-subtables + * HEST substructures contained in subtables */ -/* XPF Machine Check Error Bank */ - -typedef struct acpi_hest_xpf_error_bank +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +typedef struct acpi_hest_ia_error_bank { UINT8 BankNumber; UINT8 ClearStatusOnInit; UINT8 StatusFormat; - UINT8 ConfigWriteEnable; + UINT8 Reserved; UINT32 ControlRegister; - UINT64 ControlInitData; + UINT64 ControlData; UINT32 StatusRegister; UINT32 AddressRegister; UINT32 MiscRegister; -} ACPI_HEST_XPF_ERROR_BANK; - - -/* Generic Error Status */ - -typedef struct acpi_hest_generic_status -{ - UINT32 BlockStatus; - UINT32 RawDataOffset; - UINT32 RawDataLength; - UINT32 DataLength; - UINT32 ErrorSeverity; - -} ACPI_HEST_GENERIC_STATUS; - - -/* Generic Error Data */ - -typedef struct acpi_hest_generic_data -{ - UINT8 SectionType[16]; - UINT32 ErrorSeverity; - UINT16 Revision; - UINT8 ValidationBits; - UINT8 Flags; - UINT32 ErrorDataLength; - UINT8 FruId[16]; - UINT8 FruText[20]; - -} ACPI_HEST_GENERIC_DATA; +} ACPI_HEST_IA_ERROR_BANK; -/* Common HEST structure for PCI/AER types below (6,7,8) */ +/* Common HEST sub-structure for PCI/AER structures below (6,7,8) */ typedef struct acpi_hest_aer_common { - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 Bus; UINT16 Device; UINT16 Function; UINT16 DeviceControl; - UINT16 Reserved; - UINT32 UncorrectableErrorMask; - UINT32 UncorrectableErrorSeverity; - UINT32 CorrectableErrorMask; - UINT32 AdvancedErrorCapabilities; + UINT16 Reserved2; + UINT32 UncorrectableMask; + UINT32 UncorrectableSeverity; + UINT32 CorrectableMask; + UINT32 AdvancedCapabilities; } ACPI_HEST_AER_COMMON; +/* Masks for HEST Flags fields */ + +#define ACPI_HEST_FIRMWARE_FIRST (1) +#define ACPI_HEST_GLOBAL (1<<1) + /* Hardware Error Notification */ @@ -835,87 +610,69 @@ enum AcpiHestNotifyTypes ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ }; +/* Values for ConfigWriteEnable bitfield above */ + +#define ACPI_HEST_TYPE (1) +#define ACPI_HEST_POLL_INTERVAL (1<<1) +#define ACPI_HEST_POLL_THRESHOLD_VALUE (1<<2) +#define ACPI_HEST_POLL_THRESHOLD_WINDOW (1<<3) +#define ACPI_HEST_ERR_THRESHOLD_VALUE (1<<4) +#define ACPI_HEST_ERR_THRESHOLD_WINDOW (1<<5) + /* * HEST subtables - * - * From WHEA Design Document, 16 May 2007. - * Note: There is no subtable type 2 in this version of the document, - * and there are two different subtable type 3s. */ - /* 0: XPF Machine Check Exception */ +/* 0: IA32 Machine Check Exception */ -typedef struct acpi_hest_xpf_machine_check +typedef struct acpi_hest_ia_machine_check { ACPI_HEST_HEADER Header; - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; - UINT8 Reserved1; - UINT32 RecordsToPreAllocate; + UINT8 Enabled; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT64 GlobalCapabilityData; UINT64 GlobalControlData; UINT8 NumHardwareBanks; - UINT8 Reserved2[7]; + UINT8 Reserved3[7]; -} ACPI_HEST_XPF_MACHINE_CHECK; +} ACPI_HEST_IA_MACHINE_CHECK; -/* 1: XPF Corrected Machine Check */ +/* 1: IA32 Corrected Machine Check */ -typedef struct acpi_table_hest_xpf_corrected +typedef struct acpi_hest_ia_corrected { ACPI_HEST_HEADER Header; - UINT16 SourceId; - UINT16 ConfigWriteEnable; + UINT16 Reserved1; UINT8 Flags; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; ACPI_HEST_NOTIFY Notify; UINT8 NumHardwareBanks; - UINT8 Reserved[3]; + UINT8 Reserved2[3]; -} ACPI_HEST_XPF_CORRECTED; +} ACPI_HEST_IA_CORRECTED; -/* 3: XPF Non-Maskable Interrupt */ +/* 2: IA32 Non-Maskable Interrupt */ -typedef struct acpi_hest_xpf_nmi +typedef struct acpi_hest_ia_nmi { ACPI_HEST_HEADER Header; - UINT16 SourceId; UINT32 Reserved; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 MaxRawDataLength; -} ACPI_HEST_XPF_NMI; +} ACPI_HEST_IA_NMI; -/* 4: IPF Corrected Machine Check */ - -typedef struct acpi_hest_ipf_corrected -{ - ACPI_HEST_HEADER Header; - UINT8 Enabled; - UINT8 Reserved; - -} ACPI_HEST_IPF_CORRECTED; - - -/* 5: IPF Corrected Platform Error */ - -typedef struct acpi_hest_ipf_corrected_platform -{ - ACPI_HEST_HEADER Header; - UINT8 Enabled; - UINT8 Reserved; - -} ACPI_HEST_IPF_CORRECTED_PLATFORM; - +/* 3,4,5: Not used */ /* 6: PCI Express Root Port AER */ @@ -944,9 +701,9 @@ typedef struct acpi_hest_aer_bridge { ACPI_HEST_HEADER Header; ACPI_HEST_AER_COMMON Aer; - UINT32 SecondaryUncorrectableErrorMask; - UINT32 SecondaryUncorrectableErrorSeverity; - UINT32 SecondaryAdvancedCapabilities; + UINT32 UncorrectableMask2; + UINT32 UncorrectableSeverity2; + UINT32 AdvancedCapabilities2; } ACPI_HEST_AER_BRIDGE; @@ -956,156 +713,60 @@ typedef struct acpi_hest_aer_bridge typedef struct acpi_hest_generic { ACPI_HEST_HEADER Header; - UINT16 SourceId; UINT16 RelatedSourceId; - UINT8 ConfigWriteEnable; + UINT8 Reserved; UINT8 Enabled; - UINT32 RecordsToPreAllocate; + UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; UINT32 MaxRawDataLength; ACPI_GENERIC_ADDRESS ErrorStatusAddress; ACPI_HEST_NOTIFY Notify; - UINT32 ErrorStatusBlockLength; + UINT32 ErrorBlockLength; } ACPI_HEST_GENERIC; -/******************************************************************************* - * - * HPET - High Precision Event Timer table - * - ******************************************************************************/ +/* Generic Error Status block */ -typedef struct acpi_table_hpet +typedef struct acpi_hest_generic_status { - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 Id; /* Hardware ID of event timer block */ - ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ - UINT8 Sequence; /* HPET sequence number */ - UINT16 MinimumTick; /* Main counter min tick, periodic mode */ - UINT8 Flags; - -} ACPI_TABLE_HPET; - -/*! Flags */ - -#define ACPI_HPET_PAGE_PROTECT (1) /* 00: No page protection */ -#define ACPI_HPET_PAGE_PROTECT_4 (1<<1) /* 01: 4KB page protected */ -#define ACPI_HPET_PAGE_PROTECT_64 (1<<2) /* 02: 64KB page protected */ - -/*! [End] no source code translation !*/ - + UINT32 BlockStatus; + UINT32 RawDataOffset; + UINT32 RawDataLength; + UINT32 DataLength; + UINT32 ErrorSeverity; -/******************************************************************************* - * - * IBFT - Boot Firmware Table - * - ******************************************************************************/ +} ACPI_HEST_GENERIC_STATUS; -typedef struct acpi_table_ibft -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved[12]; +/* Values for BlockStatus flags above */ -} ACPI_TABLE_IBFT; +#define ACPI_HEST_UNCORRECTABLE (1) +#define ACPI_HEST_CORRECTABLE (1<<1) +#define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ -/* IBFT common subtable header */ +/* Generic Error Data entry */ -typedef struct acpi_ibft_header +typedef struct acpi_hest_generic_data { - UINT8 Type; - UINT8 Version; - UINT16 Length; - UINT8 Index; + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; -} ACPI_IBFT_HEADER; - - -/* Values for Type field above */ - -enum AcpiIbftType -{ - ACPI_IBFT_TYPE_NOT_USED = 0, - ACPI_IBFT_TYPE_CONTROL = 1, - ACPI_IBFT_TYPE_INITIATOR = 2, - ACPI_IBFT_TYPE_NIC = 3, - ACPI_IBFT_TYPE_TARGET = 4, - ACPI_IBFT_TYPE_EXTENSIONS = 5, - ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ -}; - - -/* IBFT subtables */ - -typedef struct acpi_ibft_control -{ - ACPI_IBFT_HEADER Header; - UINT16 Extensions; - UINT16 InitiatorOffset; - UINT16 Nic0Offset; - UINT16 Target0Offset; - UINT16 Nic1Offset; - UINT16 Target1Offset; - -} ACPI_IBFT_CONTROL; - -typedef struct acpi_ibft_initiator -{ - ACPI_IBFT_HEADER Header; - UINT8 SnsServer[16]; - UINT8 SlpServer[16]; - UINT8 PrimaryServer[16]; - UINT8 SecondaryServer[16]; - UINT16 NameLength; - UINT16 NameOffset; - -} ACPI_IBFT_INITIATOR; - -typedef struct acpi_ibft_nic -{ - ACPI_IBFT_HEADER Header; - UINT8 IpAddress[16]; - UINT8 SubnetMaskPrefix; - UINT8 Origin; - UINT8 Gateway[16]; - UINT8 PrimaryDns[16]; - UINT8 SecondaryDns[16]; - UINT8 Dhcp[16]; - UINT16 Vlan; - UINT8 MacAddress[6]; - UINT16 PciAddress; - UINT16 NameLength; - UINT16 NameOffset; - -} ACPI_IBFT_NIC; - -typedef struct acpi_ibft_target -{ - ACPI_IBFT_HEADER Header; - UINT8 TargetIpAddress[16]; - UINT16 TargetIpSocket; - UINT8 TargetBootLun[8]; - UINT8 ChapType; - UINT8 NicAssociation; - UINT16 TargetNameLength; - UINT16 TargetNameOffset; - UINT16 ChapNameLength; - UINT16 ChapNameOffset; - UINT16 ChapSecretLength; - UINT16 ChapSecretOffset; - UINT16 ReverseChapNameLength; - UINT16 ReverseChapNameOffset; - UINT16 ReverseChapSecretLength; - UINT16 ReverseChapSecretOffset; - -} ACPI_IBFT_TARGET; +} ACPI_HEST_GENERIC_DATA; /******************************************************************************* * * MADT - Multiple APIC Description Table + * Version 3 * ******************************************************************************/ @@ -1117,9 +778,9 @@ typedef struct acpi_table_madt } ACPI_TABLE_MADT; -/* Flags */ +/* Masks for Flags field above */ -#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ /* Values for PCATCompat flag */ @@ -1127,7 +788,7 @@ typedef struct acpi_table_madt #define ACPI_MADT_MULTIPLE_APIC 1 -/* Values for subtable type in ACPI_SUBTABLE_HEADER */ +/* Values for MADT subtable type in ACPI_SUBTABLE_HEADER */ enum AcpiMadtType { @@ -1161,6 +822,7 @@ typedef struct acpi_madt_local_apic } ACPI_MADT_LOCAL_APIC; + /* 1: IO APIC */ typedef struct acpi_madt_io_apic @@ -1173,6 +835,7 @@ typedef struct acpi_madt_io_apic } ACPI_MADT_IO_APIC; + /* 2: Interrupt Override */ typedef struct acpi_madt_interrupt_override @@ -1185,6 +848,7 @@ typedef struct acpi_madt_interrupt_override } ACPI_MADT_INTERRUPT_OVERRIDE; + /* 3: NMI Source */ typedef struct acpi_madt_nmi_source @@ -1195,6 +859,7 @@ typedef struct acpi_madt_nmi_source } ACPI_MADT_NMI_SOURCE; + /* 4: Local APIC NMI */ typedef struct acpi_madt_local_apic_nmi @@ -1206,6 +871,7 @@ typedef struct acpi_madt_local_apic_nmi } ACPI_MADT_LOCAL_APIC_NMI; + /* 5: Address Override */ typedef struct acpi_madt_local_apic_override @@ -1216,6 +882,7 @@ typedef struct acpi_madt_local_apic_override } ACPI_MADT_LOCAL_APIC_OVERRIDE; + /* 6: I/O Sapic */ typedef struct acpi_madt_io_sapic @@ -1228,6 +895,7 @@ typedef struct acpi_madt_io_sapic } ACPI_MADT_IO_SAPIC; + /* 7: Local Sapic */ typedef struct acpi_madt_local_sapic @@ -1243,6 +911,7 @@ typedef struct acpi_madt_local_sapic } ACPI_MADT_LOCAL_SAPIC; + /* 8: Platform Interrupt Source */ typedef struct acpi_madt_interrupt_source @@ -1258,11 +927,12 @@ typedef struct acpi_madt_interrupt_source } ACPI_MADT_INTERRUPT_SOURCE; -/* Flags field above */ +/* Masks for Flags field above */ #define ACPI_MADT_CPEI_OVERRIDE (1) -/* 9: Processor Local X2APIC (07/2008) */ + +/* 9: Processor Local X2APIC (ACPI 4.0) */ typedef struct acpi_madt_local_x2apic { @@ -1274,7 +944,8 @@ typedef struct acpi_madt_local_x2apic } ACPI_MADT_LOCAL_X2APIC; -/* 10: Local X2APIC NMI (07/2008) */ + +/* 10: Local X2APIC NMI (ACPI 4.0) */ typedef struct acpi_madt_local_x2apic_nmi { @@ -1315,34 +986,40 @@ typedef struct acpi_madt_local_x2apic_nmi /******************************************************************************* * - * MCFG - PCI Memory Mapped Configuration table and sub-table + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * Version 1 * ******************************************************************************/ -typedef struct acpi_table_mcfg +typedef struct acpi_table_msct { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved[8]; + UINT32 ProximityOffset; /* Location of proximity info struct(s) */ + UINT32 MaxProximityDomains;/* Max number of proximity domains */ + UINT32 MaxClockDomains; /* Max number of clock domains */ + UINT64 MaxAddress; /* Max physical address in system */ -} ACPI_TABLE_MCFG; +} ACPI_TABLE_MSCT; -/* Subtable */ +/* Subtable - Maximum Proximity Domain Information. Version 1 */ -typedef struct acpi_mcfg_allocation +typedef struct acpi_msct_proximity { - UINT64 Address; /* Base address, processor-relative */ - UINT16 PciSegment; /* PCI segment group number */ - UINT8 StartBusNumber; /* Starting PCI Bus number */ - UINT8 EndBusNumber; /* Final PCI Bus number */ - UINT32 Reserved; + UINT8 Revision; + UINT8 Length; + UINT32 RangeStart; /* Start of domain range */ + UINT32 RangeEnd; /* End of domain range */ + UINT32 ProcessorCapacity; + UINT64 MemoryCapacity; /* In bytes */ -} ACPI_MCFG_ALLOCATION; +} ACPI_MSCT_PROXIMITY; /******************************************************************************* * * SBST - Smart Battery Specification Table + * Version 1 * ******************************************************************************/ @@ -1359,6 +1036,7 @@ typedef struct acpi_table_sbst /******************************************************************************* * * SLIT - System Locality Distance Information Table + * Version 1 * ******************************************************************************/ @@ -1371,68 +1049,10 @@ typedef struct acpi_table_slit } ACPI_TABLE_SLIT; -/******************************************************************************* - * - * SPCR - Serial Port Console Redirection table - * - ******************************************************************************/ - -typedef struct acpi_table_spcr -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ - UINT8 Reserved[3]; - ACPI_GENERIC_ADDRESS SerialPort; - UINT8 InterruptType; - UINT8 PcInterrupt; - UINT32 Interrupt; - UINT8 BaudRate; - UINT8 Parity; - UINT8 StopBits; - UINT8 FlowControl; - UINT8 TerminalType; - UINT8 Reserved1; - UINT16 PciDeviceId; - UINT16 PciVendorId; - UINT8 PciBus; - UINT8 PciDevice; - UINT8 PciFunction; - UINT32 PciFlags; - UINT8 PciSegment; - UINT32 Reserved2; - -} ACPI_TABLE_SPCR; - - -/******************************************************************************* - * - * SPMI - Server Platform Management Interface table - * - ******************************************************************************/ - -typedef struct acpi_table_spmi -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Reserved; - UINT8 InterfaceType; - UINT16 SpecRevision; /* Version of IPMI */ - UINT8 InterruptType; - UINT8 GpeNumber; /* GPE assigned */ - UINT8 Reserved1; - UINT8 PciDeviceFlag; - UINT32 Interrupt; - ACPI_GENERIC_ADDRESS IpmiRegister; - UINT8 PciSegment; - UINT8 PciBus; - UINT8 PciDevice; - UINT8 PciFunction; - -} ACPI_TABLE_SPMI; - - /******************************************************************************* * * SRAT - System Resource Affinity Table + * Version 3 * ******************************************************************************/ @@ -1472,6 +1092,11 @@ typedef struct acpi_srat_cpu_affinity } ACPI_SRAT_CPU_AFFINITY; +/* Flags */ + +#define ACPI_SRAT_CPU_USE_AFFINITY (1) /* 00: Use affinity structure */ + + /* 1: Memory Affinity */ typedef struct acpi_srat_mem_affinity @@ -1493,7 +1118,8 @@ typedef struct acpi_srat_mem_affinity #define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ #define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ -/* 2: Processor Local X2_APIC Affinity (07/2008) */ + +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ typedef struct acpi_srat_x2apic_cpu_affinity { @@ -1502,6 +1128,8 @@ typedef struct acpi_srat_x2apic_cpu_affinity UINT32 ProximityDomain; UINT32 ApicId; UINT32 Flags; + UINT32 ClockDomain; + UINT32 Reserved2; } ACPI_SRAT_X2APIC_CPU_AFFINITY; @@ -1510,132 +1138,6 @@ typedef struct acpi_srat_x2apic_cpu_affinity #define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ -/******************************************************************************* - * - * TCPA - Trusted Computing Platform Alliance table - * - ******************************************************************************/ - -typedef struct acpi_table_tcpa -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT16 Reserved; - UINT32 MaxLogLength; /* Maximum length for the event log area */ - UINT64 LogAddress; /* Address of the event log area */ - -} ACPI_TABLE_TCPA; - - -/******************************************************************************* - * - * UEFI - UEFI Boot optimization Table - * - ******************************************************************************/ - -typedef struct acpi_table_uefi -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT8 Identifier[16]; /* UUID identifier */ - UINT16 DataOffset; /* Offset of remaining data in table */ - UINT8 Data; - -} ACPI_TABLE_UEFI; - - -/******************************************************************************* - * - * WDAT - Watchdog Action Table - * - ******************************************************************************/ - -typedef struct acpi_table_wdat -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 HeaderLength; /* Watchdog Header Length */ - UINT16 PciSegment; /* PCI Segment number */ - UINT8 PciBus; /* PCI Bus number */ - UINT8 PciDevice; /* PCI Device number */ - UINT8 PciFunction; /* PCI Function number */ - UINT8 Reserved[3]; - UINT32 TimerPeriod; /* Period of one timer count (msec) */ - UINT32 MaxCount; /* Maximum counter value supported */ - UINT32 MinCount; /* Minimum counter value */ - UINT8 Flags; - UINT8 Reserved2[3]; - UINT32 Entries; /* Number of watchdog entries that follow */ - -} ACPI_TABLE_WDAT; - -/* WDAT Instruction Entries (actions) */ - -typedef struct acpi_wdat_entry -{ - ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ - -} ACPI_WDAT_ENTRY; - -/* Values for Action field above */ - -enum AcpiWdatActions -{ - ACPI_WDAT_RESET = 1, - ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, - ACPI_WDAT_GET_COUNTDOWN = 5, - ACPI_WDAT_SET_COUNTDOWN = 6, - ACPI_WDAT_GET_RUNNING_STATE = 8, - ACPI_WDAT_SET_RUNNING_STATE = 9, - ACPI_WDAT_GET_STOPPED_STATE = 10, - ACPI_WDAT_SET_STOPPED_STATE = 11, - ACPI_WDAT_GET_REBOOT = 16, - ACPI_WDAT_SET_REBOOT = 17, - ACPI_WDAT_GET_SHUTDOWN = 18, - ACPI_WDAT_SET_SHUTDOWN = 19, - ACPI_WDAT_GET_STATUS = 32, - ACPI_WDAT_SET_STATUS = 33, - ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ -}; - -/* Values for Instruction field above */ - -enum AcpiWdatInstructions -{ - ACPI_WDAT_READ_VALUE = 0, - ACPI_WDAT_READ_COUNTDOWN = 1, - ACPI_WDAT_WRITE_VALUE = 2, - ACPI_WDAT_WRITE_COUNTDOWN = 3, - ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ - ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ -}; - - -/******************************************************************************* - * - * WDRT - Watchdog Resource Table - * - ******************************************************************************/ - -typedef struct acpi_table_wdrt -{ - ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT32 HeaderLength; /* Watchdog Header Length */ - UINT8 PciSegment; /* PCI Segment number */ - UINT8 PciBus; /* PCI Bus number */ - UINT8 PciDevice; /* PCI Device number */ - UINT8 PciFunction; /* PCI Function number */ - UINT32 TimerPeriod; /* Period of one timer count (msec) */ - UINT32 MaxCount; /* Maximum counter value supported */ - UINT32 MinCount; /* Minimum counter value */ - UINT8 Flags; - UINT8 Reserved[3]; - UINT32 Entries; /* Number of watchdog entries that follow */ - -} ACPI_TABLE_WDRT; - -/* Flags */ - -#define ACPI_WDRT_TIMER_ENABLED (1) /* 00: Timer enabled */ - - /* Reset to default packing */ #pragma pack() diff --git a/sys/contrib/dev/acpica-unix/include/actbl2.h b/sys/contrib/dev/acpica-unix/include/actbl2.h index 6b3a88bcf1..a89ae9e6a3 100644 --- a/sys/contrib/dev/acpica-unix/include/actbl2.h +++ b/sys/contrib/dev/acpica-unix/include/actbl2.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,1089 @@ #ifndef __ACTBL2_H__ #define __ACTBL2_H__ -/* Code moved to both actbl.h and actbl1.h */ + +/******************************************************************************* + * + * Additional ACPI Tables (2) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are defined by third-party specifications, and are + * not defined directly by the ACPI specification itself. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ +#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ +#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ +#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ +#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ +#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ +#define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ +#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ +#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ +#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ +#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ +#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ +#define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ +#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ +#define ACPI_SIG_WDDT "WDDT" /* Watchdog Timer Description Table */ +#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ + +#ifdef ACPI_UNDEFINED_TABLES +/* + * These tables have been seen in the field, but no definition has been found + */ +#define ACPI_SIG_ATKG "ATKG" +#define ACPI_SIG_GSCI "GSCI" /* GMCH SCI table */ +#define ACPI_SIG_IEIT "IEIT" +#endif + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * ASF - Alert Standard Format table (Signature "ASF!") + * Revision 0x10 + * + * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_asf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_ASF; + + +/* ASF subtable header */ + +typedef struct acpi_asf_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_ASF_HEADER; + + +/* Values for Type field above */ + +enum AcpiAsfType +{ + ACPI_ASF_TYPE_INFO = 0, + ACPI_ASF_TYPE_ALERT = 1, + ACPI_ASF_TYPE_CONTROL = 2, + ACPI_ASF_TYPE_BOOT = 3, + ACPI_ASF_TYPE_ADDRESS = 4, + ACPI_ASF_TYPE_RESERVED = 5 +}; + +/* + * ASF subtables + */ + +/* 0: ASF Information */ + +typedef struct acpi_asf_info +{ + ACPI_ASF_HEADER Header; + UINT8 MinResetValue; + UINT8 MinPollInterval; + UINT16 SystemId; + UINT32 MfgId; + UINT8 Flags; + UINT8 Reserved2[3]; + +} ACPI_ASF_INFO; + +/* Masks for Flags field above */ + +#define ACPI_ASF_SMBUS_PROTOCOLS (1) + + +/* 1: ASF Alerts */ + +typedef struct acpi_asf_alert +{ + ACPI_ASF_HEADER Header; + UINT8 AssertMask; + UINT8 DeassertMask; + UINT8 Alerts; + UINT8 DataLength; + +} ACPI_ASF_ALERT; + +typedef struct acpi_asf_alert_data +{ + UINT8 Address; + UINT8 Command; + UINT8 Mask; + UINT8 Value; + UINT8 SensorType; + UINT8 Type; + UINT8 Offset; + UINT8 SourceType; + UINT8 Severity; + UINT8 SensorNumber; + UINT8 Entity; + UINT8 Instance; + +} ACPI_ASF_ALERT_DATA; + + +/* 2: ASF Remote Control */ + +typedef struct acpi_asf_remote +{ + ACPI_ASF_HEADER Header; + UINT8 Controls; + UINT8 DataLength; + UINT16 Reserved2; + +} ACPI_ASF_REMOTE; + +typedef struct acpi_asf_control_data +{ + UINT8 Function; + UINT8 Address; + UINT8 Command; + UINT8 Value; + +} ACPI_ASF_CONTROL_DATA; + + +/* 3: ASF RMCP Boot Options */ + +typedef struct acpi_asf_rmcp +{ + ACPI_ASF_HEADER Header; + UINT8 Capabilities[7]; + UINT8 CompletionCode; + UINT32 EnterpriseId; + UINT8 Command; + UINT16 Parameter; + UINT16 BootOptions; + UINT16 OemParameters; + +} ACPI_ASF_RMCP; + + +/* 4: ASF Address */ + +typedef struct acpi_asf_address +{ + ACPI_ASF_HEADER Header; + UINT8 EpromAddress; + UINT8 Devices; + +} ACPI_ASF_ADDRESS; + + +/******************************************************************************* + * + * BOOT - Simple Boot Flag Table + * Version 1 + * + * Conforms to the "Simple Boot Flag Specification", Version 2.1 + * + ******************************************************************************/ + +typedef struct acpi_table_boot +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ + UINT8 Reserved[3]; + +} ACPI_TABLE_BOOT; + + +/******************************************************************************* + * + * DBGP - Debug Port table + * Version 1 + * + * Conforms to the "Debug Port Specification", Version 1.00, 2/9/2000 + * + ******************************************************************************/ + +typedef struct acpi_table_dbgp +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS DebugPort; + +} ACPI_TABLE_DBGP; + + +/******************************************************************************* + * + * DMAR - DMA Remapping table + * Version 1 + * + * Conforms to "Intel Virtualization Technology for Directed I/O", + * Version 1.2, Sept. 2008 + * + ******************************************************************************/ + +typedef struct acpi_table_dmar +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Width; /* Host Address Width */ + UINT8 Flags; + UINT8 Reserved[10]; + +} ACPI_TABLE_DMAR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INTR_REMAP (1) + + +/* DMAR subtable header */ + +typedef struct acpi_dmar_header +{ + UINT16 Type; + UINT16 Length; + +} ACPI_DMAR_HEADER; + +/* Values for subtable type in ACPI_DMAR_HEADER */ + +enum AcpiDmarType +{ + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_ATSR = 2, + ACPI_DMAR_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ +}; + + +/* DMAR Device Scope structure */ + +typedef struct acpi_dmar_device_scope +{ + UINT8 EntryType; + UINT8 Length; + UINT16 Reserved; + UINT8 EnumerationId; + UINT8 Bus; + +} ACPI_DMAR_DEVICE_SCOPE; + +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ + +enum AcpiDmarScopeType +{ + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, + ACPI_DMAR_SCOPE_TYPE_HPET = 4, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +}; + +typedef struct acpi_dmar_pci_path +{ + UINT8 Device; + UINT8 Function; + +} ACPI_DMAR_PCI_PATH; + + +/* + * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER + */ + +/* 0: Hardware Unit Definition */ + +typedef struct acpi_dmar_hardware_unit +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + UINT64 Address; /* Register Base Address */ + +} ACPI_DMAR_HARDWARE_UNIT; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INCLUDE_ALL (1) + + +/* 1: Reserved Memory Defininition */ + +typedef struct acpi_dmar_reserved_memory +{ + ACPI_DMAR_HEADER Header; + UINT16 Reserved; + UINT16 Segment; + UINT64 BaseAddress; /* 4K aligned base address */ + UINT64 EndAddress; /* 4K aligned limit address */ + +} ACPI_DMAR_RESERVED_MEMORY; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALLOW_ALL (1) + + +/* 2: Root Port ATS Capability Reporting Structure */ + +typedef struct acpi_dmar_atsr +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + +} ACPI_DMAR_ATSR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALL_PORTS (1) + + +/* 3: Remapping Hardware Static Affinity Structure */ + +typedef struct acpi_dmar_rhsa +{ + ACPI_DMAR_HEADER Header; + UINT32 Reserved; + UINT64 BaseAddress; + UINT32 ProximityDomain; + +} ACPI_DMAR_RHSA; + + +/******************************************************************************* + * + * HPET - High Precision Event Timer table + * Version 1 + * + * Conforms to "IA-PC HPET (High Precision Event Timers) Specification", + * Version 1.0a, October 2004 + * + ******************************************************************************/ + +typedef struct acpi_table_hpet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Id; /* Hardware ID of event timer block */ + ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ + UINT8 Sequence; /* HPET sequence number */ + UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT8 Flags; + +} ACPI_TABLE_HPET; + +/* Masks for Flags field above */ + +#define ACPI_HPET_PAGE_PROTECT_MASK (3) + +/* Values for Page Protect flags */ + +enum AcpiHpetPageProtect +{ + ACPI_HPET_NO_PAGE_PROTECT = 0, + ACPI_HPET_PAGE_PROTECT4 = 1, + ACPI_HPET_PAGE_PROTECT64 = 2 +}; + + +/******************************************************************************* + * + * IBFT - Boot Firmware Table + * Version 1 + * + * Conforms to "iSCSI Boot Firmware Table (iBFT) as Defined in ACPI 3.0b + * Specification", Version 1.01, March 1, 2007 + * + * Note: It appears that this table is not intended to appear in the RSDT/XSDT. + * Therefore, it is not currently supported by the disassembler. + * + ******************************************************************************/ + +typedef struct acpi_table_ibft +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[12]; + +} ACPI_TABLE_IBFT; + + +/* IBFT common subtable header */ + +typedef struct acpi_ibft_header +{ + UINT8 Type; + UINT8 Version; + UINT16 Length; + UINT8 Index; + UINT8 Flags; + +} ACPI_IBFT_HEADER; + +/* Values for Type field above */ + +enum AcpiIbftType +{ + ACPI_IBFT_TYPE_NOT_USED = 0, + ACPI_IBFT_TYPE_CONTROL = 1, + ACPI_IBFT_TYPE_INITIATOR = 2, + ACPI_IBFT_TYPE_NIC = 3, + ACPI_IBFT_TYPE_TARGET = 4, + ACPI_IBFT_TYPE_EXTENSIONS = 5, + ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* IBFT subtables */ + +typedef struct acpi_ibft_control +{ + ACPI_IBFT_HEADER Header; + UINT16 Extensions; + UINT16 InitiatorOffset; + UINT16 Nic0Offset; + UINT16 Target0Offset; + UINT16 Nic1Offset; + UINT16 Target1Offset; + +} ACPI_IBFT_CONTROL; + +typedef struct acpi_ibft_initiator +{ + ACPI_IBFT_HEADER Header; + UINT8 SnsServer[16]; + UINT8 SlpServer[16]; + UINT8 PrimaryServer[16]; + UINT8 SecondaryServer[16]; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_INITIATOR; + +typedef struct acpi_ibft_nic +{ + ACPI_IBFT_HEADER Header; + UINT8 IpAddress[16]; + UINT8 SubnetMaskPrefix; + UINT8 Origin; + UINT8 Gateway[16]; + UINT8 PrimaryDns[16]; + UINT8 SecondaryDns[16]; + UINT8 Dhcp[16]; + UINT16 Vlan; + UINT8 MacAddress[6]; + UINT16 PciAddress; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_NIC; + +typedef struct acpi_ibft_target +{ + ACPI_IBFT_HEADER Header; + UINT8 TargetIpAddress[16]; + UINT16 TargetIpSocket; + UINT8 TargetBootLun[8]; + UINT8 ChapType; + UINT8 NicAssociation; + UINT16 TargetNameLength; + UINT16 TargetNameOffset; + UINT16 ChapNameLength; + UINT16 ChapNameOffset; + UINT16 ChapSecretLength; + UINT16 ChapSecretOffset; + UINT16 ReverseChapNameLength; + UINT16 ReverseChapNameOffset; + UINT16 ReverseChapSecretLength; + UINT16 ReverseChapSecretOffset; + +} ACPI_IBFT_TARGET; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * Version 1 + * + * Conforms to "AMD I/O Virtualization Technology (IOMMU) Specification", + * Revision 1.26, February 2009. + * + ******************************************************************************/ + +typedef struct acpi_table_ivrs +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Info; /* Common virtualization info */ + UINT64 Reserved; + +} ACPI_TABLE_IVRS; + +/* Values for Info field above */ + +#define ACPI_IVRS_PHYSICAL_SIZE 0x00007F00 /* 7 bits, physical address size */ +#define ACPI_IVRS_VIRTUAL_SIZE 0x003F8000 /* 7 bits, virtual address size */ +#define ACPI_IVRS_ATS_RESERVED 0x00400000 /* ATS address translation range reserved */ + + +/* IVRS subtable header */ + +typedef struct acpi_ivrs_header +{ + UINT8 Type; /* Subtable type */ + UINT8 Flags; + UINT16 Length; /* Subtable length */ + UINT16 DeviceId; /* ID of IOMMU */ + +} ACPI_IVRS_HEADER; + +/* Values for subtable Type above */ + +enum AcpiIvrsType +{ + ACPI_IVRS_TYPE_HARDWARE = 0x10, + ACPI_IVRS_TYPE_MEMORY1 = 0x20, + ACPI_IVRS_TYPE_MEMORY2 = 0x21, + ACPI_IVRS_TYPE_MEMORY3 = 0x22 +}; + +/* Masks for Flags field above for IVHD subtable */ + +#define ACPI_IVHD_TT_ENABLE (1) +#define ACPI_IVHD_PASS_PW (1<<1) +#define ACPI_IVHD_RES_PASS_PW (1<<2) +#define ACPI_IVHD_ISOC (1<<3) +#define ACPI_IVHD_IOTLB (1<<4) + +/* Masks for Flags field above for IVMD subtable */ + +#define ACPI_IVMD_UNITY (1) +#define ACPI_IVMD_READ (1<<1) +#define ACPI_IVMD_WRITE (1<<2) +#define ACPI_IVMD_EXCLUSION_RANGE (1<<3) + + +/* + * IVRS subtables, correspond to Type in ACPI_IVRS_HEADER + */ + +/* 0x10: I/O Virtualization Hardware Definition Block (IVHD) */ + +typedef struct acpi_ivrs_hardware +{ + ACPI_IVRS_HEADER Header; + UINT16 CapabilityOffset; /* Offset for IOMMU control fields */ + UINT64 BaseAddress; /* IOMMU control registers */ + UINT16 PciSegmentGroup; + UINT16 Info; /* MSI number and unit ID */ + UINT32 Reserved; + +} ACPI_IVRS_HARDWARE; + +/* Masks for Info field above */ + +#define ACPI_IVHD_MSI_NUMBER_MASK 0x001F /* 5 bits, MSI message number */ +#define ACPI_IVHD_UNIT_ID_MASK 0x1F00 /* 5 bits, UnitID */ + + +/* + * Device Entries for IVHD subtable, appear after ACPI_IVRS_HARDWARE structure. + * Upper two bits of the Type field are the (encoded) length of the structure. + * Currently, only 4 and 8 byte entries are defined. 16 and 32 byte entries + * are reserved for future use but not defined. + */ +typedef struct acpi_ivrs_de_header +{ + UINT8 Type; + UINT16 Id; + UINT8 DataSetting; + +} ACPI_IVRS_DE_HEADER; + +/* Length of device entry is in the top two bits of Type field above */ + +#define ACPI_IVHD_ENTRY_LENGTH 0xC0 + +/* Values for device entry Type field above */ + +enum AcpiIvrsDeviceEntryType +{ + /* 4-byte device entries, all use ACPI_IVRS_DEVICE4 */ + + ACPI_IVRS_TYPE_PAD4 = 0, + ACPI_IVRS_TYPE_ALL = 1, + ACPI_IVRS_TYPE_SELECT = 2, + ACPI_IVRS_TYPE_START = 3, + ACPI_IVRS_TYPE_END = 4, + + /* 8-byte device entries */ + + ACPI_IVRS_TYPE_PAD8 = 64, + ACPI_IVRS_TYPE_NOT_USED = 65, + ACPI_IVRS_TYPE_ALIAS_SELECT = 66, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_ALIAS_START = 67, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_EXT_SELECT = 70, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_EXT_START = 71, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_SPECIAL = 72 /* Uses ACPI_IVRS_DEVICE8C */ +}; + +/* Values for Data field above */ + +#define ACPI_IVHD_INIT_PASS (1) +#define ACPI_IVHD_EINT_PASS (1<<1) +#define ACPI_IVHD_NMI_PASS (1<<2) +#define ACPI_IVHD_SYSTEM_MGMT (3<<4) +#define ACPI_IVHD_LINT0_PASS (1<<6) +#define ACPI_IVHD_LINT1_PASS (1<<7) + + +/* Types 0-4: 4-byte device entry */ + +typedef struct acpi_ivrs_device4 +{ + ACPI_IVRS_DE_HEADER Header; + +} ACPI_IVRS_DEVICE4; + +/* Types 66-67: 8-byte device entry */ + +typedef struct acpi_ivrs_device8a +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Reserved1; + UINT16 UsedId; + UINT8 Reserved2; + +} ACPI_IVRS_DEVICE8A; + +/* Types 70-71: 8-byte device entry */ + +typedef struct acpi_ivrs_device8b +{ + ACPI_IVRS_DE_HEADER Header; + UINT32 ExtendedData; + +} ACPI_IVRS_DEVICE8B; + +/* Values for ExtendedData above */ + +#define ACPI_IVHD_ATS_DISABLED (1<<31) + +/* Type 72: 8-byte device entry */ + +typedef struct acpi_ivrs_device8c +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Handle; + UINT16 UsedId; + UINT8 Variety; + +} ACPI_IVRS_DEVICE8C; + +/* Values for Variety field above */ + +#define ACPI_IVHD_IOAPIC 1 +#define ACPI_IVHD_HPET 2 + + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition Block (IVMD) */ + +typedef struct acpi_ivrs_memory +{ + ACPI_IVRS_HEADER Header; + UINT16 AuxData; + UINT64 Reserved; + UINT64 StartAddress; + UINT64 MemoryLength; + +} ACPI_IVRS_MEMORY; + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and sub-table + * Version 1 + * + * Conforms to "PCI Firmware Specification", Revision 3.0, June 20, 2005 + * + ******************************************************************************/ + +typedef struct acpi_table_mcfg +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[8]; + +} ACPI_TABLE_MCFG; + + +/* Subtable */ + +typedef struct acpi_mcfg_allocation +{ + UINT64 Address; /* Base address, processor-relative */ + UINT16 PciSegment; /* PCI segment group number */ + UINT8 StartBusNumber; /* Starting PCI Bus number */ + UINT8 EndBusNumber; /* Final PCI Bus number */ + UINT32 Reserved; + +} ACPI_MCFG_ALLOCATION; + + +/******************************************************************************* + * + * MCHI - Management Controller Host Interface Table + * Version 1 + * + * Conforms to "Management Component Transport Protocol (MCTP) Host + * Interface Specification", Revision 1.0.0a, October 13, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_mchi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; + UINT8 Protocol; + UINT64 ProtocolData; + UINT8 InterruptType; + UINT8 Gpe; + UINT8 PciDeviceFlag; + UINT32 GlobalInterrupt; + ACPI_GENERIC_ADDRESS ControlRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + +} ACPI_TABLE_MCHI; + + +/******************************************************************************* + * + * SPCR - Serial Port Console Redirection table + * Version 1 + * + * Conforms to "Serial Port Console Redirection Table", + * Version 1.00, January 11, 2002 + * + ******************************************************************************/ + +typedef struct acpi_table_spcr +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS SerialPort; + UINT8 InterruptType; + UINT8 PcInterrupt; + UINT32 Interrupt; + UINT8 BaudRate; + UINT8 Parity; + UINT8 StopBits; + UINT8 FlowControl; + UINT8 TerminalType; + UINT8 Reserved1; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT32 PciFlags; + UINT8 PciSegment; + UINT32 Reserved2; + +} ACPI_TABLE_SPCR; + +/* Masks for PciFlags field above */ + +#define ACPI_SPCR_DO_NOT_DISABLE (1) + + +/******************************************************************************* + * + * SPMI - Server Platform Management Interface table + * Version 5 + * + * Conforms to "Intelligent Platform Management Interface Specification + * Second Generation v2.0", Document Revision 1.0, February 12, 2004 with + * June 12, 2009 markup. + * + ******************************************************************************/ + +typedef struct acpi_table_spmi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; + UINT8 Reserved; /* Must be 1 */ + UINT16 SpecRevision; /* Version of IPMI */ + UINT8 InterruptType; + UINT8 GpeNumber; /* GPE assigned */ + UINT8 Reserved1; + UINT8 PciDeviceFlag; + UINT32 Interrupt; + ACPI_GENERIC_ADDRESS IpmiRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT8 Reserved2; + +} ACPI_TABLE_SPMI; + +/* Values for InterfaceType above */ + +enum AcpiSpmiInterfaceTypes +{ + ACPI_SPMI_NOT_USED = 0, + ACPI_SPMI_KEYBOARD = 1, + ACPI_SPMI_SMI = 2, + ACPI_SPMI_BLOCK_TRANSFER = 3, + ACPI_SPMI_SMBUS = 4, + ACPI_SPMI_RESERVED = 5 /* 5 and above are reserved */ +}; + + +/******************************************************************************* + * + * TCPA - Trusted Computing Platform Alliance table + * Version 1 + * + * Conforms to "TCG PC Specific Implementation Specification", + * Version 1.1, August 18, 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_tcpa +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Reserved; + UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA; + + +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * Version 1 + * + * Conforms to "Unified Extensible Firmware Interface Specification", + * Version 2.3, May 8, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_uefi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Identifier[16]; /* UUID identifier */ + UINT16 DataOffset; /* Offset of remaining data in table */ + +} ACPI_TABLE_UEFI; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * Version 1 + * + * Conforms to "Windows ACPI Emulated Devices Table", version 1.0, April 6, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_waet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Flags; + +} ACPI_TABLE_WAET; + +/* Masks for Flags field above */ + +#define ACPI_WAET_RTC_NO_ACK (1) /* RTC requires no int acknowledge */ +#define ACPI_WAET_TIMER_ONE_READ (1<<1) /* PM timer requires only one read */ + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * Version 1 + * + * Conforms to "Hardware Watchdog Timers Design Specification", + * Copyright 2006 Microsoft Corporation. + * + ******************************************************************************/ + +typedef struct acpi_table_wdat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; /* Watchdog Header Length */ + UINT16 PciSegment; /* PCI Segment number */ + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 Reserved[3]; + UINT32 TimerPeriod; /* Period of one timer count (msec) */ + UINT32 MaxCount; /* Maximum counter value supported */ + UINT32 MinCount; /* Minimum counter value */ + UINT8 Flags; + UINT8 Reserved2[3]; + UINT32 Entries; /* Number of watchdog entries that follow */ + +} ACPI_TABLE_WDAT; + +/* Masks for Flags field above */ + +#define ACPI_WDAT_ENABLED (1) +#define ACPI_WDAT_STOPPED 0x80 + + +/* WDAT Instruction Entries (actions) */ + +typedef struct acpi_wdat_entry +{ + UINT8 Action; + UINT8 Instruction; + UINT16 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT32 Value; /* Value used with Read/Write register */ + UINT32 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WDAT_ENTRY; + +/* Values for Action field above */ + +enum AcpiWdatActions +{ + ACPI_WDAT_RESET = 1, + ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, + ACPI_WDAT_GET_COUNTDOWN = 5, + ACPI_WDAT_SET_COUNTDOWN = 6, + ACPI_WDAT_GET_RUNNING_STATE = 8, + ACPI_WDAT_SET_RUNNING_STATE = 9, + ACPI_WDAT_GET_STOPPED_STATE = 10, + ACPI_WDAT_SET_STOPPED_STATE = 11, + ACPI_WDAT_GET_REBOOT = 16, + ACPI_WDAT_SET_REBOOT = 17, + ACPI_WDAT_GET_SHUTDOWN = 18, + ACPI_WDAT_SET_SHUTDOWN = 19, + ACPI_WDAT_GET_STATUS = 32, + ACPI_WDAT_SET_STATUS = 33, + ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiWdatInstructions +{ + ACPI_WDAT_READ_VALUE = 0, + ACPI_WDAT_READ_COUNTDOWN = 1, + ACPI_WDAT_WRITE_VALUE = 2, + ACPI_WDAT_WRITE_COUNTDOWN = 3, + ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ + ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ +}; + + +/******************************************************************************* + * + * WDDT - Watchdog Descriptor Table + * Version 1 + * + * Conforms to "Using the Intel ICH Family Watchdog Timer (WDT)", + * Version 001, September 2002 + * + ******************************************************************************/ + +typedef struct acpi_table_wddt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 SpecVersion; + UINT16 TableVersion; + UINT16 PciVendorId; + ACPI_GENERIC_ADDRESS Address; + UINT16 MaxCount; /* Maximum counter value supported */ + UINT16 MinCount; /* Minimum counter value supported */ + UINT16 Period; + UINT16 Status; + UINT16 Capability; + +} ACPI_TABLE_WDDT; + +/* Flags for Status field above */ + +#define ACPI_WDDT_AVAILABLE (1) +#define ACPI_WDDT_ACTIVE (1<<1) +#define ACPI_WDDT_TCO_OS_OWNED (1<<2) +#define ACPI_WDDT_USER_RESET (1<<11) +#define ACPI_WDDT_WDT_RESET (1<<12) +#define ACPI_WDDT_POWER_FAIL (1<<13) +#define ACPI_WDDT_UNKNOWN_RESET (1<<14) + +/* Flags for Capability field above */ + +#define ACPI_WDDT_AUTO_RESET (1) +#define ACPI_WDDT_ALERT_SUPPORT (1<<1) + + +/******************************************************************************* + * + * WDRT - Watchdog Resource Table + * Version 1 + * + * Conforms to "Watchdog Timer Hardware Requirements for Windows Server 2003", + * Version 1.01, August 28, 2006 + * + ******************************************************************************/ + +typedef struct acpi_table_wdrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS ControlRegister; + ACPI_GENERIC_ADDRESS CountRegister; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 PciSegment; /* PCI Segment number */ + UINT16 MaxCount; /* Maximum counter value supported */ + UINT8 Units; + +} ACPI_TABLE_WDRT; + + +/* Reset to default packing */ + +#pragma pack() #endif /* __ACTBL2_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/actypes.h b/sys/contrib/dev/acpica-unix/include/actypes.h index 8f970d9729..6a40ad5e6d 100644 --- a/sys/contrib/dev/acpica-unix/include/actypes.h +++ b/sys/contrib/dev/acpica-unix/include/actypes.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -188,7 +188,6 @@ * * ACPI_SIZE 16/32/64-bit unsigned value * ACPI_NATIVE_INT 16/32/64-bit signed value - * */ /******************************************************************************* @@ -205,6 +204,16 @@ typedef COMPILER_DEPENDENT_INT64 INT64; /*! [End] no source code translation !*/ +/* + * Value returned by AcpiOsGetThreadId. There is no standard "thread_id" + * across operating systems or even the various UNIX systems. Since ACPICA + * only needs the thread ID as a unique thread identifier, we use a UINT64 + * as the only common data type - it will accommodate any type of pointer or + * any type of integer. It is up to the host-dependent OSL to cast the + * native thread ID type to a UINT64 (in AcpiOsGetThreadId). + */ +#define ACPI_THREAD_ID UINT64 + /******************************************************************************* * @@ -286,12 +295,6 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; * ******************************************************************************/ -/* Value returned by AcpiOsGetThreadId */ - -#ifndef ACPI_THREAD_ID -#define ACPI_THREAD_ID ACPI_SIZE -#endif - /* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ #ifndef ACPI_CPU_FLAGS @@ -415,7 +418,7 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; /* PM Timer ticks per second (HZ) */ -#define PM_TIMER_FREQUENCY 3579545 +#define PM_TIMER_FREQUENCY 3579545 /******************************************************************************* @@ -456,36 +459,6 @@ typedef UINT8 ACPI_OWNER_ID; #define ACPI_OWNER_ID_MAX 0xFF -typedef struct uint64_struct -{ - UINT32 Lo; - UINT32 Hi; - -} UINT64_STRUCT; - -typedef union uint64_overlay -{ - UINT64 Full; - UINT64_STRUCT Part; - -} UINT64_OVERLAY; - -typedef struct uint32_struct -{ - UINT32 Lo; - UINT32 Hi; - -} UINT32_STRUCT; - - -/* - * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI - * version 2, integers are 64 bits. Note that this pertains to the ACPI integer - * type only, not other integers used in the implementation of the ACPI CA - * subsystem. - */ -typedef UINT64 ACPI_INTEGER; -#define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 #define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ #define ACPI_MAX64_DECIMAL_DIGITS 20 @@ -500,6 +473,19 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ #define ACPI_DO_NOT_WAIT 0 +/* + * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are 32 bits. + * In ACPI version 2 (2000) and later, integers are 64 bits. Note that this + * pertains to the ACPI integer type only, not to other integers used in the + * implementation of the ACPICA subsystem. + * + * 01/2010: This type is obsolete and has been removed from the entire ACPICA + * code base. It remains here for compatibility with device drivers that use + * the type. However, it will be removed in the future. + */ +typedef UINT64 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT64_MAX + /******************************************************************************* * @@ -744,53 +730,38 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_GPE_MAX 0xFF #define ACPI_NUM_GPE 256 +/* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */ + #define ACPI_GPE_ENABLE 0 #define ACPI_GPE_DISABLE 1 - +#define ACPI_GPE_CONDITIONAL_ENABLE 2 /* * GPE info flags - Per GPE - * +-+-+-+---+---+-+ - * |7|6|5|4:3|2:1|0| - * +-+-+-+---+---+-+ - * | | | | | | - * | | | | | +--- Interrupt type: Edge or Level Triggered - * | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime - * | | | +--- Type of dispatch -- to method, handler, or none - * | | +--- Enabled for runtime? - * | +--- Enabled for wake? - * +--- Unused + * +-------+-+-+---+ + * | 7:4 |3|2|1:0| + * +-------+-+-+---+ + * | | | | + * | | | +-- Type of dispatch:to method, handler, notify, or none + * | | +----- Interrupt type: edge or level triggered + * | +------- Is a Wake GPE + * +------------ */ -#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 -#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 -#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 +#define ACPI_GPE_DISPATCH_NONE (UINT8) 0x00 +#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x01 +#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x02 +#define ACPI_GPE_DISPATCH_NOTIFY (UINT8) 0x03 +#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x03 -#define ACPI_GPE_TYPE_MASK (UINT8) 0x06 -#define ACPI_GPE_TYPE_WAKE_RUN (UINT8) 0x06 -#define ACPI_GPE_TYPE_WAKE (UINT8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0x04 /* Default */ - -#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x18 -#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x08 -#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x10 -#define ACPI_GPE_DISPATCH_NOT_USED (UINT8) 0x00 /* Default */ - -#define ACPI_GPE_RUN_ENABLE_MASK (UINT8) 0x20 -#define ACPI_GPE_RUN_ENABLED (UINT8) 0x20 -#define ACPI_GPE_RUN_DISABLED (UINT8) 0x00 /* Default */ - -#define ACPI_GPE_WAKE_ENABLE_MASK (UINT8) 0x40 -#define ACPI_GPE_WAKE_ENABLED (UINT8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (UINT8) 0x00 /* Default */ +#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x04 +#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 +#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x04 -#define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ +#define ACPI_GPE_CAN_WAKE (UINT8) 0x08 /* * Flags for GPE and Lock interfaces */ -#define ACPI_EVENT_WAKE_ENABLE 0x2 /* AcpiGpeEnable */ -#define ACPI_EVENT_WAKE_DISABLE 0x2 /* AcpiGpeDisable */ - #define ACPI_NOT_ISR 0x1 #define ACPI_ISR 0x0 @@ -816,7 +787,8 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 #define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 -#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_IPMI (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 8 #define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 127 @@ -889,7 +861,7 @@ typedef union acpi_object struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_INTEGER */ - ACPI_INTEGER Value; /* The actual number */ + UINT64 Value; /* The actual number */ } Integer; struct @@ -1043,10 +1015,26 @@ typedef void /* * Various handlers and callback procedures */ +typedef +void (*ACPI_GBL_EVENT_HANDLER) ( + UINT32 EventType, + ACPI_HANDLE Device, + UINT32 EventNumber, + void *Context); + +#define ACPI_EVENT_TYPE_GPE 0 +#define ACPI_EVENT_TYPE_FIXED 1 + typedef UINT32 (*ACPI_EVENT_HANDLER) ( void *Context); +typedef +UINT32 (*ACPI_GPE_HANDLER) ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + void *Context); + typedef void (*ACPI_NOTIFY_HANDLER) ( ACPI_HANDLE Device, @@ -1056,7 +1044,6 @@ void (*ACPI_NOTIFY_HANDLER) ( typedef void (*ACPI_OBJECT_HANDLER) ( ACPI_HANDLE Object, - UINT32 Function, void *Data); typedef @@ -1094,7 +1081,7 @@ ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); @@ -1112,57 +1099,88 @@ ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( typedef ACPI_STATUS (*ACPI_WALK_CALLBACK) ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, UINT32 NestingLevel, void *Context, void **ReturnValue); +typedef +UINT32 (*ACPI_INTERFACE_HANDLER) ( + ACPI_STRING InterfaceName, + UINT32 Supported); + /* Interrupt handler return values */ #define ACPI_INTERRUPT_NOT_HANDLED 0x00 #define ACPI_INTERRUPT_HANDLED 0x01 +/* GPE handler return values */ + +#define ACPI_REENABLE_GPE 0x80 + -/* Length of _HID, _UID, _CID, and UUID values */ +/* Length of 32-bit EISAID values when converted back to a string */ + +#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ + +/* Length of UUID (string) values */ -#define ACPI_DEVICE_ID_LENGTH 0x09 -#define ACPI_MAX_CID_LENGTH 48 #define ACPI_UUID_LENGTH 16 -/* Common string version of device HIDs and UIDs */ + +/* Structures used for device/processor HID, UID, CID */ typedef struct acpi_device_id { - char Value[ACPI_DEVICE_ID_LENGTH]; + UINT32 Length; /* Length of string + null */ + char *String; } ACPI_DEVICE_ID; -/* Common string version of device CIDs */ - -typedef struct acpi_compatible_id +typedef struct acpi_device_id_list { - char Value[ACPI_MAX_CID_LENGTH]; + UINT32 Count; /* Number of IDs in Ids array */ + UINT32 ListSize; /* Size of list, including ID strings */ + ACPI_DEVICE_ID Ids[1]; /* ID array */ -} ACPI_COMPATIBLE_ID; +} ACPI_DEVICE_ID_LIST; -typedef struct acpi_compatible_id_list +/* + * Structure returned from AcpiGetObjectInfo. + * Optimized for both 32- and 64-bit builds + */ +typedef struct acpi_device_info { - UINT32 Count; - UINT32 Size; - ACPI_COMPATIBLE_ID Id[1]; + UINT32 InfoSize; /* Size of info, including ID strings */ + UINT32 Name; /* ACPI object Name */ + ACPI_OBJECT_TYPE Type; /* ACPI object Type */ + UINT8 ParamCount; /* If a method, required parameter count */ + UINT8 Valid; /* Indicates which optional fields are valid */ + UINT8 Flags; /* Miscellaneous info */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ + UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ + UINT32 CurrentStatus; /* _STA value */ + UINT64 Address; /* _ADR value */ + ACPI_DEVICE_ID HardwareId; /* _HID value */ + ACPI_DEVICE_ID UniqueId; /* _UID value */ + ACPI_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ -} ACPI_COMPATIBLE_ID_LIST; +} ACPI_DEVICE_INFO; + +/* Values for Flags field above (AcpiGetObjectInfo) */ +#define ACPI_PCI_ROOT_BRIDGE 0x01 -/* Structure and flags for AcpiGetObjectInfo */ +/* Flags for Valid field above (AcpiGetObjectInfo) */ -#define ACPI_VALID_STA 0x0001 -#define ACPI_VALID_ADR 0x0002 -#define ACPI_VALID_HID 0x0004 -#define ACPI_VALID_UID 0x0008 -#define ACPI_VALID_CID 0x0010 -#define ACPI_VALID_SXDS 0x0020 +#define ACPI_VALID_STA 0x01 +#define ACPI_VALID_ADR 0x02 +#define ACPI_VALID_HID 0x04 +#define ACPI_VALID_UID 0x08 +#define ACPI_VALID_CID 0x10 +#define ACPI_VALID_SXDS 0x20 +#define ACPI_VALID_SXWS 0x40 /* Flags for _STA method */ @@ -1174,36 +1192,6 @@ typedef struct acpi_compatible_id_list #define ACPI_STA_BATTERY_PRESENT 0x10 -#define ACPI_COMMON_OBJ_INFO \ - ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ - ACPI_NAME Name /* ACPI object Name */ - - -typedef struct acpi_obj_info_header -{ - ACPI_COMMON_OBJ_INFO; - -} ACPI_OBJ_INFO_HEADER; - - -/* Structure returned from Get Object Info */ - -typedef struct acpi_device_info -{ - ACPI_COMMON_OBJ_INFO; - - UINT32 ParamCount; /* If a method, required parameter count */ - UINT32 Valid; /* Indicates which fields below are valid */ - UINT32 CurrentStatus; /* _STA value */ - ACPI_INTEGER Address; /* _ADR value if any */ - ACPI_DEVICE_ID HardwareId; /* _HID value if any */ - ACPI_DEVICE_ID UniqueId; /* _UID value if any */ - UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ - ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ - -} ACPI_DEVICE_INFO; - - /* Context structs for address space handlers */ typedef struct acpi_pci_id @@ -1215,7 +1203,6 @@ typedef struct acpi_pci_id } ACPI_PCI_ID; - typedef struct acpi_mem_space_context { UINT32 Length; diff --git a/sys/contrib/dev/acpica-unix/include/acutils.h b/sys/contrib/dev/acpica-unix/include/acutils.h index 5573754e89..cef6ab3e6f 100644 --- a/sys/contrib/dev/acpica-unix/include/acutils.h +++ b/sys/contrib/dev/acpica-unix/include/acutils.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -235,7 +235,7 @@ AcpiUtGetEventName ( char AcpiUtHexToAsciiChar ( - ACPI_INTEGER Integer, + UINT64 Integer, UINT32 Position); BOOLEAN @@ -470,7 +470,7 @@ AcpiUtValueExit ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - ACPI_INTEGER Value); + UINT64 Value); void AcpiUtPtrExit ( @@ -536,10 +536,6 @@ AcpiUtDeleteInternalObjectList ( * uteval - object evaluation */ ACPI_STATUS -AcpiUtOsiImplementation ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, char *Path, @@ -550,32 +546,39 @@ ACPI_STATUS AcpiUtEvaluateNumericObject ( char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_INTEGER *Address); + UINT64 *Value); ACPI_STATUS -AcpiUtExecute_HID ( +AcpiUtExecute_STA ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Hid); + UINT32 *StatusFlags); ACPI_STATUS -AcpiUtExecute_CID ( +AcpiUtExecutePowerMethods ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_COMPATIBLE_ID_LIST **ReturnCidList); + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues); + +/* + * utids - device ID support + */ ACPI_STATUS -AcpiUtExecute_STA ( +AcpiUtExecute_HID ( ACPI_NAMESPACE_NODE *DeviceNode, - UINT32 *StatusFlags); + ACPI_DEVICE_ID **ReturnId); ACPI_STATUS AcpiUtExecute_UID ( ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Uid); + ACPI_DEVICE_ID **ReturnId); ACPI_STATUS -AcpiUtExecute_Sxds ( +AcpiUtExecute_CID ( ACPI_NAMESPACE_NODE *DeviceNode, - UINT8 *Highest); + ACPI_DEVICE_ID_LIST **ReturnCidList); + /* * utlock - reader/writer locks @@ -636,6 +639,10 @@ ACPI_OPERAND_OBJECT * AcpiUtCreatePackageObject ( UINT32 Count); +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 Value); + ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject ( ACPI_SIZE BufferSize); @@ -650,6 +657,34 @@ AcpiUtGetObjectSize( ACPI_SIZE *ObjLength); +/* + * utosi - Support for the _OSI predefined control method + */ +ACPI_STATUS +AcpiUtInitializeInterfaces ( + void); + +void +AcpiUtInterfaceTerminate ( + void); + +ACPI_STATUS +AcpiUtInstallInterface ( + ACPI_STRING InterfaceName); + +ACPI_STATUS +AcpiUtRemoveInterface ( + ACPI_STRING InterfaceName); + +ACPI_INTERFACE_INFO * +AcpiUtGetInterface ( + ACPI_STRING InterfaceName); + +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState); + + /* * utstate - Generic state creation/cache routines */ @@ -709,16 +744,16 @@ AcpiUtDeleteGenericState ( */ ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER InDividend, - ACPI_INTEGER InDivisor, - ACPI_INTEGER *OutQuotient, - ACPI_INTEGER *OutRemainder); + UINT64 InDividend, + UINT64 InDivisor, + UINT64 *OutQuotient, + UINT64 *OutRemainder); ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER InDividend, + UINT64 InDividend, UINT32 Divisor, - ACPI_INTEGER *OutQuotient, + UINT64 *OutQuotient, UINT32 *OutRemainder); /* @@ -728,6 +763,10 @@ const char * AcpiUtValidateException ( ACPI_STATUS Status); +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id); + BOOLEAN AcpiUtIsAmlTable ( ACPI_TABLE_HEADER *Table); @@ -751,6 +790,10 @@ void AcpiUtStrupr ( char *SrcString); +void +AcpiUtStrlwr ( + char *SrcString); + void AcpiUtPrintString ( char *String, @@ -773,7 +816,7 @@ ACPI_STATUS AcpiUtStrtoul64 ( char *String, UINT32 Base, - ACPI_INTEGER *RetInteger); + UINT64 *RetInteger); /* Values for Base above (16=Hex, 10=Decimal) */ @@ -924,7 +967,44 @@ AcpiUtCreateList ( UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache); +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ -#endif + +/* + * utxferror - various error/warning output functions + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +void +AcpiUtNamespaceError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus); + +void +AcpiUtMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *Node, + const char *Path, + ACPI_STATUS LookupStatus); #endif /* _ACUTILS_H */ diff --git a/sys/contrib/dev/acpica-unix/include/amlcode.h b/sys/contrib/dev/acpica-unix/include/amlcode.h index 7694acc14c..df9657f8ee 100644 --- a/sys/contrib/dev/acpica-unix/include/amlcode.h +++ b/sys/contrib/dev/acpica-unix/include/amlcode.h @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -485,6 +485,7 @@ typedef enum REGION_SMBUS, REGION_CMOS, REGION_PCI_BAR, + REGION_IPMI, REGION_DATA_TABLE, /* Internal use only */ REGION_FIXED_HW = 0x7F @@ -578,17 +579,11 @@ typedef enum } AML_ACCESS_ATTRIBUTE; -/* Bit fields in MethodFlags byte */ +/* Bit fields in the AML MethodFlags byte */ #define AML_METHOD_ARG_COUNT 0x07 #define AML_METHOD_SERIALIZED 0x08 #define AML_METHOD_SYNC_LEVEL 0xF0 -/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */ - -#define AML_METHOD_INTERNAL_ONLY 0x01 -#define AML_METHOD_RESERVED1 0x02 -#define AML_METHOD_RESERVED2 0x04 - #endif /* __AMLCODE_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/amlresrc.h b/sys/contrib/dev/acpica-unix/include/amlresrc.h index 689564c628..ba0e324f13 100644 --- a/sys/contrib/dev/acpica-unix/include/amlresrc.h +++ b/sys/contrib/dev/acpica-unix/include/amlresrc.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -300,6 +300,12 @@ typedef struct aml_resource_large_header } AML_RESOURCE_LARGE_HEADER; +/* General Flags for address space resource descriptors */ + +#define ACPI_RESOURCE_FLAG_DEC 2 +#define ACPI_RESOURCE_FLAG_MIF 4 +#define ACPI_RESOURCE_FLAG_MAF 8 + typedef struct aml_resource_memory24 { AML_RESOURCE_LARGE_HEADER_COMMON diff --git a/sys/contrib/dev/acpica-unix/include/platform/accygwin.h b/sys/contrib/dev/acpica-unix/include/platform/accygwin.h index e9585b44b1..624dfdff11 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/accygwin.h +++ b/sys/contrib/dev/acpica-unix/include/platform/accygwin.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -121,7 +121,6 @@ */ #define ACPI_USE_SYSTEM_CLIBRARY #define ACPI_USE_DO_WHILE_0 -#define ACPI_THREAD_ID pthread_t #define ACPI_FLUSH_CPU_CACHE() /* * This is needed since sem_timedwait does not appear to work properly @@ -151,10 +150,12 @@ #define __cdecl #endif -#ifdef _ANSI -#define inline -#endif +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (GLptr) Acq=1; else Acq=0; +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = 1 + +/* On Cygwin, pthread_t is a pointer */ +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (pthread)) /* Cygwin uses GCC */ diff --git a/sys/contrib/dev/acpica-unix/include/platform/acefi.h b/sys/contrib/dev/acpica-unix/include/platform/acefi.h index 40afaa401c..6ecda765dd 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acefi.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acefi.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/platform/acenv.h b/sys/contrib/dev/acpica-unix/include/platform/acenv.h index 58cb03bfc1..39498586e8 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acenv.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acenv.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -148,9 +148,10 @@ #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_LARGE_NAMESPACE_NODE #define ACPI_DATA_TABLE_DISASSEMBLY +#define ACPI_SINGLE_THREADED #endif -/* AcpiExec configuration */ +/* AcpiExec and AcpiBin configuration */ #ifdef ACPI_EXEC_APP #define ACPI_APPLICATION @@ -159,6 +160,11 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif +#ifdef ACPI_BIN_APP +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + /* Linkable ACPICA library */ #ifdef ACPI_LIBRARY @@ -262,11 +268,11 @@ /* Global Lock acquire/release */ #ifndef ACPI_ACQUIRE_GLOBAL_LOCK -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = 1 +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acquired) Acquired = 1 #endif #ifndef ACPI_RELEASE_GLOBAL_LOCK -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) Acq = 0 +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = 0 #endif /* Flush CPU cache - used when going to sleep. Wbinvd or similar. */ @@ -275,6 +281,12 @@ #define ACPI_FLUSH_CPU_CACHE() #endif +/* "inline" keywords - configurable since inline is not standardized */ + +#ifndef ACPI_INLINE +#define ACPI_INLINE +#endif + /* * Configurable calling conventions: * @@ -424,8 +436,8 @@ typedef char *va_list; #define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) #define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) #define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) -#define ACPI_TOUPPER AcpiUtToUpper -#define ACPI_TOLOWER AcpiUtToLower +#define ACPI_TOUPPER(c) AcpiUtToUpper ((int) (c)) +#define ACPI_TOLOWER(c) AcpiUtToLower ((int) (c)) #endif /* ACPI_USE_SYSTEM_CLIBRARY */ diff --git a/sys/contrib/dev/acpica-unix/include/platform/acfreebsd.h b/sys/contrib/dev/acpica-unix/include/platform/acfreebsd.h index 20c5687c20..19e6911afc 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acfreebsd.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acfreebsd.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,7 +114,7 @@ *****************************************************************************/ #ifndef __ACFREEBSD_H__ -#define __ACFREEBSD_H__ +#define __ACFREEBSD_H__ /* FreeBSD uses GCC */ @@ -123,12 +123,11 @@ #include #include -#define ACPI_UINTPTR_T uintptr_t +#define ACPI_UINTPTR_T uintptr_t -#define ACPI_USE_LOCAL_CACHE -#define ACPI_USE_SYSTEM_CLIBRARY - -#define __cdecl +#define ACPI_USE_DO_WHILE_0 +#define ACPI_USE_LOCAL_CACHE +#define ACPI_USE_SYSTEM_CLIBRARY #ifdef _KERNEL @@ -140,17 +139,17 @@ #include "opt_acpi.h" -#define ACPI_THREAD_ID lwpid_t +#define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX #ifdef ACPI_DEBUG -#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ -#define ACPI_DISASSEMBLER +#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ +#define ACPI_DISASSEMBLER #endif #ifdef ACPI_DEBUG_OUTPUT #include "opt_ddb.h" #ifdef DDB -#define ACPI_DEBUGGER +#define ACPI_DEBUGGER #endif /* DDB */ #endif /* ACPI_DEBUG_OUTPUT */ @@ -158,7 +157,7 @@ #undef DEBUGGER_THREADING #endif /* DEBUGGER_THREADING */ -#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#define DEBUGGER_THREADING 0 /* integrated with DDB */ #else /* _KERNEL */ @@ -166,14 +165,12 @@ #include #endif -#define ACPI_THREAD_ID pthread_t +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (pthread)) -/* Not building kernel code, so use libc */ -#define ACPI_USE_STANDARD_HEADERS -#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_USE_STANDARD_HEADERS -#define __cli() -#define __sti() +#define ACPI_FLUSH_CPU_CACHE() +#define __cdecl #endif /* _KERNEL */ diff --git a/sys/contrib/dev/acpica-unix/include/platform/acgcc.h b/sys/contrib/dev/acpica-unix/include/platform/acgcc.h index 449942278c..8743a8f045 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acgcc.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acgcc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,6 +116,8 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ +#define ACPI_INLINE __inline__ + /* Function name is used for debug output. Non-ANSI, compiler-dependent */ #define ACPI_GET_FUNCTION_NAME __FUNCTION__ diff --git a/sys/contrib/dev/acpica-unix/include/platform/acintel.h b/sys/contrib/dev/acpica-unix/include/platform/acintel.h index 44197a0994..a93ccf8976 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acintel.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acintel.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,11 @@ #ifndef __ACINTEL_H__ #define __ACINTEL_H__ +/* Configuration specific to Intel 64-bit C compiler */ -#define COMPILER_DEPENDENT_INT64 __int64 -#define COMPILER_DEPENDENT_UINT64 unsigned __int64 - -#define inline __inline +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 +#define ACPI_INLINE __inline /* * Calling conventions: @@ -135,20 +135,6 @@ #define ACPI_INTERNAL_XFACE #define ACPI_INTERNAL_VAR_XFACE -/* - * Math helper functions - */ -#define ACPI_DIV_64_BY_32(n, n_hi, n_lo, d32, q32, r32) \ -{ \ - q32 = n / d32; \ - r32 = n % d32; \ -} - -#define ACPI_SHIFT_RIGHT_64(n, n_hi, n_lo) \ -{ \ - n <<= 1; \ -} - /* remark 981 - operands evaluated in no particular order */ #pragma warning(disable:981) diff --git a/sys/contrib/dev/acpica-unix/include/platform/aclinux.h b/sys/contrib/dev/acpica-unix/include/platform/aclinux.h index c6f868cdbf..76e146fbf9 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/aclinux.h +++ b/sys/contrib/dev/acpica-unix/include/platform/aclinux.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -147,7 +147,6 @@ #define ACPI_CACHE_T struct kmem_cache #define ACPI_SPINLOCK spinlock_t * #define ACPI_CPU_FLAGS unsigned long -#define ACPI_THREAD_ID struct task_struct * #else /* !__KERNEL__ */ @@ -160,7 +159,7 @@ /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE() -#define ACPI_THREAD_ID pthread_t +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (pthread)) #if defined(__ia64__) || defined(__x86_64__) #define ACPI_MACHINE_WIDTH 64 diff --git a/sys/contrib/dev/acpica-unix/include/platform/acmsvc.h b/sys/contrib/dev/acpica-unix/include/platform/acmsvc.h index 0320e74d1e..187db79c25 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acmsvc.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acmsvc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -116,8 +116,21 @@ #ifndef __ACMSVC_H__ #define __ACMSVC_H__ -#define COMPILER_DEPENDENT_INT64 __int64 -#define COMPILER_DEPENDENT_UINT64 unsigned __int64 +/* Eliminate warnings for "old" (non-secure) versions of clib functions */ + +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif + +/* Eliminate warnings for POSIX clib function names (open, write, etc.) */ + +#ifndef _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE +#endif + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 +#define ACPI_INLINE __inline /* * Calling conventions: @@ -179,5 +192,8 @@ /* warn C4131: uses old-style declarator (iASL compiler only) */ #pragma warning(disable:4131) +#if _MSC_VER > 1200 /* Versions above VC++ 6 */ +#pragma warning( disable : 4295 ) /* needed for acpredef.h array */ +#endif #endif /* __ACMSVC_H__ */ diff --git a/sys/contrib/dev/acpica-unix/include/platform/acnetbsd.h b/sys/contrib/dev/acpica-unix/include/platform/acnetbsd.h index c04851b926..b6af23eec8 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acnetbsd.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acnetbsd.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/include/platform/acos2.h b/sys/contrib/dev/acpica-unix/include/platform/acos2.h index 21e3373c24..5d692040da 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acos2.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acos2.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -158,12 +158,6 @@ unsigned short OSPMReleaseGlobalLock (void *); n_lo = (unsigned long)(val & 0xffffffff); \ } -/* IBM VAC does not have inline */ - -#if __IBMC__ || __IBMCPP__ -#define inline -#endif - #ifndef ACPI_ASL_COMPILER #define ACPI_USE_LOCAL_CACHE #undef ACPI_DEBUGGER diff --git a/sys/contrib/dev/acpica-unix/include/platform/acwin.h b/sys/contrib/dev/acpica-unix/include/platform/acwin.h index d1fa2ee22b..1a6c14af63 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acwin.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acwin.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -126,8 +126,6 @@ #define ACPI_MACHINE_WIDTH 32 -#define inline __inline - #define ACPI_USE_STANDARD_HEADERS #ifdef ACPI_DEFINE_ALTERNATE_TYPES diff --git a/sys/contrib/dev/acpica-unix/include/platform/acwin64.h b/sys/contrib/dev/acpica-unix/include/platform/acwin64.h index faec855e22..d67f4cde66 100644 --- a/sys/contrib/dev/acpica-unix/include/platform/acwin64.h +++ b/sys/contrib/dev/acpica-unix/include/platform/acwin64.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Name: acwin.h - OS specific defines, etc. + * Name: acwin64.h - OS specific defines, etc. * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/namespace/nsaccess.c b/sys/contrib/dev/acpica-unix/namespace/nsaccess.c index 172b26d3ab..e098e52b0e 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsaccess.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsaccess.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -250,8 +250,8 @@ AcpiNsRootInitialize ( #else /* Mark this as a very SPECIAL method */ - ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; - ObjDesc->Method.Implementation = AcpiUtOsiImplementation; + ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY; + ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation; #endif break; @@ -306,7 +306,7 @@ AcpiNsRootInitialize ( default: - ACPI_ERROR ((AE_INFO, "Unsupported initial type value %X", + ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X", InitVal->Type)); AcpiUtRemoveReference (ObjDesc); ObjDesc = NULL; @@ -435,7 +435,7 @@ AcpiNsLookup ( while (!AcpiNsOpensScope (PrefixNode->Type) && PrefixNode->Type != ACPI_TYPE_ANY) { - PrefixNode = AcpiNsGetParentNode (PrefixNode); + PrefixNode = PrefixNode->Parent; } } } @@ -516,7 +516,7 @@ AcpiNsLookup ( /* Backup to the parent node */ NumCarats++; - ThisNode = AcpiNsGetParentNode (ThisNode); + ThisNode = ThisNode->Parent; if (!ThisNode) { /* Current scope has no parent scope */ @@ -531,7 +531,7 @@ AcpiNsLookup ( if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Search scope is [%4.4s], path has %d carat(s)\n", + "Search scope is [%4.4s], path has %u carat(s)\n", AcpiUtGetNodeName (ThisNode), NumCarats)); } } @@ -592,7 +592,7 @@ AcpiNsLookup ( Path++; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Multi Pathname (%d Segments, Flags=%X)\n", + "Multi Pathname (%u Segments, Flags=%X)\n", NumSegments, Flags)); break; diff --git a/sys/contrib/dev/acpica-unix/namespace/nsalloc.c b/sys/contrib/dev/acpica-unix/namespace/nsalloc.c index e66c9f76a7..de9f2293b0 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsalloc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -181,23 +181,81 @@ AcpiNsCreateNode ( * * RETURN: None * - * DESCRIPTION: Delete a namespace node + * DESCRIPTION: Delete a namespace node. All node deletions must come through + * here. Detaches any attached objects, including any attached + * data. If a handler is associated with attached data, it is + * invoked before the node is deleted. * ******************************************************************************/ void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsDeleteNode); + + + /* Detach an object if there is one */ + + AcpiNsDetachObject (Node); + + /* + * Delete an attached data object if present (an object that was created + * and attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object is a data object. + */ + ObjDesc = Node->Object; + if (ObjDesc && + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + /* Invoke the attached data deletion handler if present */ + + if (ObjDesc->Data.Handler) + { + ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); + } + + AcpiUtRemoveReference (ObjDesc); + } + + /* Now we can delete the node */ + + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", + Node, AcpiGbl_CurrentNodeCount)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveNode + * + * PARAMETERS: Node - Node to be removed/deleted + * + * RETURN: None + * + * DESCRIPTION: Remove (unlink) and delete a namespace node + * + ******************************************************************************/ + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node) { ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *PrevNode; ACPI_NAMESPACE_NODE *NextNode; - ACPI_FUNCTION_TRACE_PTR (NsDeleteNode, Node); + ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); - ParentNode = AcpiNsGetParentNode (Node); + ParentNode = Node->Parent; PrevNode = NULL; NextNode = ParentNode->Child; @@ -207,42 +265,27 @@ AcpiNsDeleteNode ( while (NextNode != Node) { PrevNode = NextNode; - NextNode = PrevNode->Peer; + NextNode = NextNode->Peer; } if (PrevNode) { /* Node is not first child, unlink it */ - PrevNode->Peer = NextNode->Peer; - if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; - } + PrevNode->Peer = Node->Peer; } else { - /* Node is first child (has no previous peer) */ - - if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - /* No peers at all */ - - ParentNode->Child = NULL; - } - else - { /* Link peer list to parent */ - - ParentNode->Child = NextNode->Peer; - } + /* + * Node is first child (has no previous peer). + * Link peer list to parent + */ + ParentNode->Child = Node->Peer; } - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); - - /* Detach an object if there is one, then delete the node */ + /* Delete the node and any attached objects */ - AcpiNsDetachObject (Node); - ACPI_OS_RELEASE_OBJECT(AcpiGbl_NamespaceCache, Node); + AcpiNsDeleteNode (Node); return_VOID; } @@ -281,38 +324,47 @@ AcpiNsInstallNode ( ACPI_FUNCTION_TRACE (NsInstallNode); - /* - * Get the owner ID from the Walk state. The owner ID is used to track - * table deletion and deletion of objects created by methods. - */ if (WalkState) { + /* + * Get the owner ID from the Walk state. The owner ID is used to + * track table deletion and deletion of objects created by methods. + */ OwnerId = WalkState->OwnerId; + + if ((WalkState->MethodDesc) && + (ParentNode != WalkState->MethodNode)) + { + /* + * A method is creating a new node that is not a child of the + * method (it is non-local). Mark the executing method as having + * modified the namespace. This is used for cleanup when the + * method exits. + */ + WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_MODIFIED_NAMESPACE; + } } /* Link the new entry into the parent and existing children */ + Node->Peer = NULL; + Node->Parent = ParentNode; ChildNode = ParentNode->Child; + if (!ChildNode) { ParentNode->Child = Node; - Node->Flags |= ANOBJ_END_OF_PEER_LIST; - Node->Peer = ParentNode; } else { - while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + /* Add node to the end of the peer list */ + + while (ChildNode->Peer) { ChildNode = ChildNode->Peer; } ChildNode->Peer = Node; - - /* Clear end-of-list flag */ - - ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; - Node->Flags |= ANOBJ_END_OF_PEER_LIST; - Node->Peer = ParentNode; } /* Init the new entry */ @@ -347,9 +399,8 @@ void AcpiNsDeleteChildren ( ACPI_NAMESPACE_NODE *ParentNode) { - ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *NextNode; - UINT8 Flags; + ACPI_NAMESPACE_NODE *NodeToDelete; ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); @@ -360,51 +411,27 @@ AcpiNsDeleteChildren ( return_VOID; } - /* If no children, all done! */ - - ChildNode = ParentNode->Child; - if (!ChildNode) - { - return_VOID; - } - /* Deallocate all children at this level */ - do + NextNode = ParentNode->Child; + while (NextNode) { - /* Get the things we need */ - - NextNode = ChildNode->Peer; - Flags = ChildNode->Flags; - /* Grandchildren should have all been deleted already */ - if (ChildNode->Child) + if (NextNode->Child) { ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", - ParentNode, ChildNode)); + ParentNode, NextNode)); } - /* Now we can free this child object */ - - ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); - - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", - ChildNode, AcpiGbl_CurrentNodeCount)); - - /* Detach an object if there is one, then free the child node */ - - AcpiNsDetachObject (ChildNode); - - /* Now we can delete the node */ - - ACPI_OS_RELEASE_OBJECT(AcpiGbl_NamespaceCache, ChildNode); - - /* And move on to the next child in the list */ - - ChildNode = NextNode; - - } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + /* + * Delete this child node and move on to the next child in the list. + * No need to unlink the node since we are deleting the entire branch. + */ + NodeToDelete = NextNode; + NextNode = NextNode->Peer; + AcpiNsDeleteNode (NodeToDelete); + }; /* Clear the parent's child pointer */ @@ -432,6 +459,7 @@ AcpiNsDeleteNamespaceSubtree ( { ACPI_NAMESPACE_NODE *ChildNode = NULL; UINT32 Level = 1; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); @@ -442,6 +470,14 @@ AcpiNsDeleteNamespaceSubtree ( return_VOID; } + /* Lock namespace for possible update */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + /* * Traverse the tree of objects until we bubble back up * to where we started. @@ -490,10 +526,11 @@ AcpiNsDeleteNamespaceSubtree ( /* Move up the tree to the grandparent */ - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; } } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_VOID; } @@ -561,7 +598,7 @@ AcpiNsDeleteNamespaceByOwner ( if (DeletionNode) { AcpiNsDeleteChildren (DeletionNode); - AcpiNsDeleteNode (DeletionNode); + AcpiNsRemoveNode (DeletionNode); DeletionNode = NULL; } @@ -612,7 +649,7 @@ AcpiNsDeleteNamespaceByOwner ( /* Move up the tree to the grandparent */ - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; } } diff --git a/sys/contrib/dev/acpica-unix/namespace/nsdump.c b/sys/contrib/dev/acpica-unix/namespace/nsdump.c index 762437aa12..2bc0eba9a0 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsdump.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -286,7 +286,7 @@ AcpiNsDumpOneObject ( return (AE_OK); } - ThisNode = AcpiNsMapHandleToNode (ObjHandle); + ThisNode = AcpiNsValidateHandle (ObjHandle); if (!ThisNode) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", @@ -314,7 +314,7 @@ AcpiNsDumpOneObject ( if (Type > ACPI_TYPE_LOCAL_MAX) { - ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type)); + ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type)); } AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); @@ -537,7 +537,7 @@ AcpiNsDumpOneObject ( return (AE_OK); } - AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); + AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount); switch (Type) { @@ -725,18 +725,34 @@ AcpiNsDumpObjects ( ACPI_HANDLE StartHandle) { ACPI_WALK_INFO Info; + ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); + /* + * Just lock the entire namespace for the duration of the dump. + * We don't want any changes to the namespace during this time, + * especially the temporary nodes since we are going to display + * them also. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not acquire namespace mutex\n"); + return; + } + Info.DebugLevel = ACPI_LV_TABLES; Info.OwnerId = OwnerId; Info.DisplayType = DisplayType; (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObject, (void *) &Info, NULL); + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); } diff --git a/sys/contrib/dev/acpica-unix/namespace/nsdumpdv.c b/sys/contrib/dev/acpica-unix/namespace/nsdumpdv.c index a2456b2429..98fb8bd0a6 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsdumpdv.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsdumpdv.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -225,7 +225,7 @@ AcpiNsDumpRootDevices ( Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiNsDumpOneDevice, NULL, NULL); + AcpiNsDumpOneDevice, NULL, NULL, NULL); } #endif diff --git a/sys/contrib/dev/acpica-unix/namespace/nseval.c b/sys/contrib/dev/acpica-unix/namespace/nseval.c index 9b31a550a6..c200e92b05 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nseval.c +++ b/sys/contrib/dev/acpica-unix/namespace/nseval.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,13 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") +/* Local prototypes */ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info); + /******************************************************************************* * @@ -360,3 +367,192 @@ AcpiNsEvaluate ( return_ACPI_STATUS (Status); } + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCodeList + * + * PARAMETERS: None + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute all elements of the global module-level code list. + * Each element is executed as a single control method. + * + ******************************************************************************/ + +void +AcpiNsExecModuleCodeList ( + void) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_EVALUATE_INFO *Info; + UINT32 MethodCount = 0; + + + ACPI_FUNCTION_TRACE (NsExecModuleCodeList); + + + /* Exit now if the list is empty */ + + Next = AcpiGbl_ModuleCodeList; + if (!Next) + { + return_VOID; + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_VOID; + } + + /* Walk the list, executing each "method" */ + + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + + /* Clear the link field and execute the method */ + + Prev->Method.Mutex = NULL; + AcpiNsExecModuleCode (Prev, Info); + MethodCount++; + + /* Delete the (temporary) method object */ + + AcpiUtRemoveReference (Prev); + } + + ACPI_INFO ((AE_INFO, + "Executed %u blocks of module-level executable AML code", + MethodCount)); + + ACPI_FREE (Info); + AcpiGbl_ModuleCodeList = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCode + * + * PARAMETERS: MethodObj - Object container for the module-level code + * Info - Info block for method evaluation + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute a control method containing a block of module-level + * executable AML code. The control method is temporarily + * installed to the root node, then evaluated. + * + ******************************************************************************/ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ParentObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsExecModuleCode); + + + /* + * Get the parent node. We cheat by using the NextObject field + * of the method object descriptor. + */ + ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + MethodObj->Method.NextObject); + Type = AcpiNsGetType (ParentNode); + + /* + * Get the region handler and save it in the method object. We may need + * this if an operation region declaration causes a _REG method to be run. + * + * We can't do this in AcpiPsLinkModuleCode because + * AcpiGbl_RootNode->Object is NULL at PASS1. + */ + if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) + { + MethodObj->Method.Dispatch.Handler = + ParentNode->Object->Device.Handler; + } + + /* Must clear NextObject (AcpiNsAttachObject needs the field) */ + + MethodObj->Method.NextObject = NULL; + + /* Initialize the evaluation information block */ + + ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = ParentNode; + + /* + * Get the currently attached parent object. Add a reference, because the + * ref count will be decreased when the method object is installed to + * the parent node. + */ + ParentObj = AcpiNsGetAttachedObject (ParentNode); + if (ParentObj) + { + AcpiUtAddReference (ParentObj); + } + + /* Install the method (module-level code) in the parent node */ + + Status = AcpiNsAttachObject (ParentNode, MethodObj, + ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Execute the parent node as a control method */ + + Status = AcpiNsEvaluate (Info); + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + MethodObj->Method.AmlStart)); + + /* Delete a possible implicit return value (in slack mode) */ + + if (Info->ReturnObject) + { + AcpiUtRemoveReference (Info->ReturnObject); + } + + /* Detach the temporary method object */ + + AcpiNsDetachObject (ParentNode); + + /* Restore the original parent object */ + + if (ParentObj) + { + Status = AcpiNsAttachObject (ParentNode, ParentObj, Type); + } + else + { + ParentNode->Type = (UINT8) Type; + } + +Exit: + if (ParentObj) + { + AcpiUtRemoveReference (ParentObj); + } + return_VOID; +} + diff --git a/sys/contrib/dev/acpica-unix/namespace/nsinit.c b/sys/contrib/dev/acpica-unix/namespace/nsinit.c index c4cd6a62ed..d5f9daafbb 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsinit.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -185,25 +185,25 @@ AcpiNsInitializeObjects ( /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiNsInitOneObject, - &Info, NULL); + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " - "Buffers %hd/%hd Packages (%hd nodes)\n", + "\nInitialized %u/%u Regions %u/%u Fields %u/%u " + "Buffers %u/%u Packages (%u nodes)\n", Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.BufferInit, Info.BufferCount, Info.PackageInit, Info.PackageCount, Info.ObjectCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Control Methods found\n", Info.MethodCount)); + "%u Control Methods found\n", Info.MethodCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%hd Op Regions found\n", Info.OpRegionCount)); + "%u Op Regions found\n", Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } @@ -249,7 +249,7 @@ AcpiNsInitializeDevices ( /* Tree analysis: find all subtrees that contain _INI methods */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, &Info, NULL); + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -264,10 +264,36 @@ AcpiNsInitializeDevices ( goto ErrorExit; } + /* + * Execute the "global" _INI method that may appear at the root. This + * support is provided for Windows compatibility (Vista+) and is not + * part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->Pathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + /* Walk namespace to execute all _INIs on present devices */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, &Info, NULL); + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + /* + * Any _OSI requests should be completed by now. If the BIOS has + * requested any Windows OSI strings, we will always truncate + * I/O addresses to 16 bits -- for Windows compatibility. + */ + if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) + { + AcpiGbl_TruncateIoAddresses = TRUE; + } ACPI_FREE (Info.EvaluateInfo); if (ACPI_FAILURE (Status)) @@ -276,8 +302,8 @@ AcpiNsInitializeDevices ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nExecuted %hd _INI methods requiring %hd _STA executions " - "(examined %hd objects)\n", + "\nExecuted %u _INI methods requiring %u _STA executions " + "(examined %u objects)\n", Info.Num_INI, Info.Num_STA, Info.DeviceCount)); return_ACPI_STATUS (Status); @@ -494,7 +520,7 @@ AcpiNsFindIniMethods ( * The only _INI methods that we care about are those that are * present under Device, Processor, and Thermal objects. */ - ParentNode = AcpiNsGetParentNode (Node); + ParentNode = Node->Parent; switch (ParentNode->Type) { case ACPI_TYPE_DEVICE: @@ -506,7 +532,7 @@ AcpiNsFindIniMethods ( while (ParentNode) { ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; } break; diff --git a/sys/contrib/dev/acpica-unix/namespace/nsload.c b/sys/contrib/dev/acpica-unix/namespace/nsload.c index 10eff45cb3..45ab0dfc2d 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsload.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -376,8 +376,7 @@ AcpiNsDeleteSubtree ( /* Now delete the starting object, and we are done */ - AcpiNsDeleteNode (ChildHandle); - + AcpiNsRemoveNode (ChildHandle); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica-unix/namespace/nsnames.c b/sys/contrib/dev/acpica-unix/namespace/nsnames.c index 0dd148fa7c..59ecfd69a8 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsnames.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -176,7 +176,7 @@ AcpiNsBuildExternalPath ( /* Put the name into the buffer */ ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; /* Prefix name with the path separator */ @@ -191,7 +191,7 @@ AcpiNsBuildExternalPath ( if (Index != 0) { ACPI_ERROR ((AE_INFO, - "Could not construct external pathname; index=%X, size=%X, Path=%s", + "Could not construct external pathname; index=%u, size=%u, Path=%s", (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); return (AE_BAD_PARAMETER); @@ -298,7 +298,7 @@ AcpiNsGetPathnameLength ( return 0; } Size += ACPI_PATH_SEGMENT_LENGTH; - NextNode = AcpiNsGetParentNode (NextNode); + NextNode = NextNode->Parent; } if (!Size) @@ -337,7 +337,7 @@ AcpiNsHandleToPathname ( ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); - Node = AcpiNsMapHandleToNode (TargetHandle); + Node = AcpiNsValidateHandle (TargetHandle); if (!Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica-unix/namespace/nsobject.c b/sys/contrib/dev/acpica-unix/namespace/nsobject.c index c0163f4ea2..d2747f32a9 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsobject.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsobject.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/namespace/nsparse.c b/sys/contrib/dev/acpica-unix/namespace/nsparse.c index 58301560ae..cd4794079c 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsparse.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsparse.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -223,7 +223,7 @@ AcpiNsOneCompleteParse ( /* Parse the AML */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber)); Status = AcpiPsParseAml (WalkState); Cleanup: diff --git a/sys/contrib/dev/acpica-unix/namespace/nspredef.c b/sys/contrib/dev/acpica-unix/namespace/nspredef.c index bfd6d7b4fc..9747b4a0be 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nspredef.c +++ b/sys/contrib/dev/acpica-unix/namespace/nspredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,7 +113,7 @@ * *****************************************************************************/ -#define __NSPREDEF_C__ +#define ACPI_CREATE_PREDEFINED_TABLE #include "acpi.h" #include "accommon.h" @@ -146,17 +146,24 @@ * ******************************************************************************/ + /* Local prototypes */ static ACPI_STATUS AcpiNsCheckPackage ( - char *Pathname, - ACPI_OPERAND_OBJECT **ReturnObjectPtr, - const ACPI_PREDEFINED_INFO *Predefined); + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); static ACPI_STATUS AcpiNsCheckPackageElements ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **Elements, UINT8 Type1, UINT32 Count1, @@ -166,21 +173,20 @@ AcpiNsCheckPackageElements ( static ACPI_STATUS AcpiNsCheckObjectType ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex); static ACPI_STATUS AcpiNsCheckReference ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT *ReturnObject); -static ACPI_STATUS -AcpiNsRepairObject ( - UINT32 ExpectedBtypes, - UINT32 PackageIndex, - ACPI_OPERAND_OBJECT **ReturnObjectPtr); +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); /* * Names for the types that can be returned by the predefined objects. @@ -195,14 +201,14 @@ static const char *AcpiRtypeNames[] = "/Reference", }; -#define ACPI_NOT_PACKAGE ACPI_UINT32_MAX - /******************************************************************************* * * FUNCTION: AcpiNsCheckPredefinedNames * * PARAMETERS: Node - Namespace node for the method/object + * UserParamCount - Number of parameters actually passed + * ReturnStatus - Status from the object evaluation * ReturnObjectPtr - Pointer to the object returned from the * evaluation of a method or object * @@ -223,13 +229,14 @@ AcpiNsCheckPredefinedNames ( ACPI_STATUS Status = AE_OK; const ACPI_PREDEFINED_INFO *Predefined; char *Pathname; + ACPI_PREDEFINED_DATA *Data; /* Match the name for this method/object against the predefined list */ Predefined = AcpiNsCheckForPredefinedName (Node); - /* Get the full pathname to the object, for use in error messages */ + /* Get the full pathname to the object, for use in warning messages */ Pathname = AcpiNsGetExternalPathname (Node); if (!Pathname) @@ -248,30 +255,18 @@ AcpiNsCheckPredefinedNames ( if (!Predefined) { - goto Exit; - } - - /* If the method failed, we cannot validate the return object */ - - if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) - { - goto Exit; + goto Cleanup; } /* - * Only validate the return value on the first successful evaluation of - * the method. This ensures that any warnings will only be emitted during - * the very first evaluation of the method/object. + * If the method failed or did not actually return an object, we cannot + * validate the return object */ - if (Node->Flags & ANOBJ_EVALUATED) + if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) { - goto Exit; + goto Cleanup; } - /* Mark the node as having been successfully evaluated */ - - Node->Flags |= ANOBJ_EVALUATED; - /* * If there is no return value, check if we require a return value for * this predefined name. Either one return value is expected, or none, @@ -284,45 +279,87 @@ AcpiNsCheckPredefinedNames ( if ((Predefined->Info.ExpectedBtypes) && (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE))) { - ACPI_ERROR ((AE_INFO, - "%s: Missing expected return value", Pathname)); + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Missing expected return value")); Status = AE_AML_NO_RETURN_VALUE; } - goto Exit; + goto Cleanup; } /* - * We have a return value, but if one wasn't expected, just exit, this is - * not a problem + * 1) We have a return value, but if one wasn't expected, just exit, this is + * not a problem. For example, if the "Implicit Return" feature is + * enabled, methods will always return a value. * - * For example, if the "Implicit Return" feature is enabled, methods will - * always return a value + * 2) If the return value can be of any type, then we cannot perform any + * validation, exit. */ - if (!Predefined->Info.ExpectedBtypes) + if ((!Predefined->Info.ExpectedBtypes) || + (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) { - goto Exit; + goto Cleanup; + } + + /* Create the parameter data block for object validation */ + + Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA)); + if (!Data) + { + goto Cleanup; } + Data->Predefined = Predefined; + Data->NodeFlags = Node->Flags; + Data->Pathname = Pathname; /* - * Check that the type of the return object is what is expected for - * this predefined name + * Check that the type of the main return object is what is expected + * for this predefined name */ - Status = AcpiNsCheckObjectType (Pathname, ReturnObjectPtr, - Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE); + Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr, + Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); if (ACPI_FAILURE (Status)) { goto Exit; } - /* For returned Package objects, check the type of all sub-objects */ - - if (ReturnObject->Common.Type == ACPI_TYPE_PACKAGE) + /* + * For returned Package objects, check the type of all sub-objects. + * Note: Package may have been newly created by call above. + */ + if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE) { - Status = AcpiNsCheckPackage (Pathname, ReturnObjectPtr, Predefined); + Data->ParentPackage = *ReturnObjectPtr; + Status = AcpiNsCheckPackage (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } } + /* + * The return object was OK, or it was successfully repaired above. + * Now make some additional checks such as verifying that package + * objects are sorted correctly (if required) or buffer objects have + * the correct data width (bytes vs. dwords). These repairs are + * performed on a per-name basis, i.e., the code is specific to + * particular predefined names. + */ + Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr); + Exit: + /* + * If the object validation failed or if we successfully repaired one + * or more objects, mark the parent node to suppress further warning + * messages during the next evaluation of the same method/object. + */ + if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED)) + { + Node->Flags |= ANOBJ_EVALUATED; + } + ACPI_FREE (Data); + +Cleanup: ACPI_FREE (Pathname); return (Status); } @@ -365,11 +402,11 @@ AcpiNsCheckParameterCount ( ParamCount = Node->Object->Method.ParamCount; } - /* Argument count check for non-predefined methods/objects */ - if (!Predefined) { /* + * Check the parameter count for non-predefined methods/objects. + * * Warning if too few or too many arguments have been passed by the * caller. An incorrect number of arguments may not cause the method * to fail. However, the method will fail if there are too few @@ -377,58 +414,49 @@ AcpiNsCheckParameterCount ( */ if (UserParamCount < ParamCount) { - ACPI_WARNING ((AE_INFO, - "%s: Insufficient arguments - needs %d, found %d", - Pathname, ParamCount, UserParamCount)); + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Insufficient arguments - needs %u, found %u", + ParamCount, UserParamCount)); } else if (UserParamCount > ParamCount) { - ACPI_WARNING ((AE_INFO, - "%s: Excess arguments - needs %d, found %d", - Pathname, ParamCount, UserParamCount)); + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Excess arguments - needs %u, found %u", + ParamCount, UserParamCount)); } return; } - /* Allow two different legal argument counts (_SCP, etc.) */ - + /* + * Validate the user-supplied parameter count. + * Allow two different legal argument counts (_SCP, etc.) + */ RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; RequiredParamsOld = Predefined->Info.ParamCount >> 4; if (UserParamCount != ACPI_UINT32_MAX) { - /* Validate the user-supplied parameter count */ - if ((UserParamCount != RequiredParamsCurrent) && (UserParamCount != RequiredParamsOld)) { - ACPI_WARNING ((AE_INFO, - "%s: Parameter count mismatch - " - "caller passed %d, ACPI requires %d", - Pathname, UserParamCount, RequiredParamsCurrent)); + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Parameter count mismatch - " + "caller passed %u, ACPI requires %u", + UserParamCount, RequiredParamsCurrent)); } } - /* - * Only validate the argument count on the first successful evaluation of - * the method. This ensures that any warnings will only be emitted during - * the very first evaluation of the method/object. - */ - if (Node->Flags & ANOBJ_EVALUATED) - { - return; - } - /* * Check that the ASL-defined parameter count is what is expected for - * this predefined name. + * this predefined name (parameter count as defined by the ACPI + * specification) */ if ((ParamCount != RequiredParamsCurrent) && (ParamCount != RequiredParamsOld)) { - ACPI_WARNING ((AE_INFO, - "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d", - Pathname, ParamCount, RequiredParamsCurrent)); + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags, + "Parameter count mismatch - ASL declared %u, ACPI requires %u", + ParamCount, RequiredParamsCurrent)); } } @@ -466,8 +494,6 @@ AcpiNsCheckForPredefinedName ( { if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) { - /* Return pointer to this table entry */ - return (ThisName); } @@ -483,7 +509,7 @@ AcpiNsCheckForPredefinedName ( ThisName++; } - return (NULL); + return (NULL); /* Not found */ } @@ -491,10 +517,9 @@ AcpiNsCheckForPredefinedName ( * * FUNCTION: AcpiNsCheckPackage * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * PARAMETERS: Data - Pointer to validation data structure * ReturnObjectPtr - Pointer to the object returned from the * evaluation of a method or object - * Predefined - Pointer to entry in predefined name table * * RETURN: Status * @@ -505,20 +530,16 @@ AcpiNsCheckForPredefinedName ( static ACPI_STATUS AcpiNsCheckPackage ( - char *Pathname, - ACPI_OPERAND_OBJECT **ReturnObjectPtr, - const ACPI_PREDEFINED_INFO *Predefined) + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; const ACPI_PREDEFINED_INFO *Package; - ACPI_OPERAND_OBJECT *SubPackage; ACPI_OPERAND_OBJECT **Elements; - ACPI_OPERAND_OBJECT **SubElements; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; UINT32 ExpectedCount; UINT32 Count; UINT32 i; - UINT32 j; ACPI_FUNCTION_NAME (NsCheckPackage); @@ -526,11 +547,17 @@ AcpiNsCheckPackage ( /* The package info for this name is in the next table entry */ - Package = Predefined + 1; + Package = Data->Predefined + 1; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s Validating return Package of Type %X, Count %X\n", - Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + + /* + * For variable-length Packages, we can safely remove all embedded + * and trailing NULL package elements + */ + AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject); /* Extract package count and elements array */ @@ -541,8 +568,8 @@ AcpiNsCheckPackage ( if (!Count) { - ACPI_WARNING ((AE_INFO, - "%s: Return Package has no elements (empty)", Pathname)); + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package has no elements (empty)")); return (AE_AML_OPERAND_VALUE); } @@ -570,20 +597,17 @@ AcpiNsCheckPackage ( } else if (Count > ExpectedCount) { - ACPI_WARNING ((AE_INFO, + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, "%s: Return Package is larger than needed - " - "found %u, expected %u", Pathname, Count, ExpectedCount)); + "found %u, expected %u\n", + Data->Pathname, Count, ExpectedCount)); } /* Validate all elements of the returned package */ - Status = AcpiNsCheckPackageElements (Pathname, Elements, + Status = AcpiNsCheckPackageElements (Data, Elements, Package->RetInfo.ObjectType1, Package->RetInfo.Count1, Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } break; @@ -595,7 +619,7 @@ AcpiNsCheckPackage ( */ for (i = 0; i < Count; i++) { - Status = AcpiNsCheckObjectType (Pathname, Elements, + Status = AcpiNsCheckObjectType (Data, Elements, Package->RetInfo.ObjectType1, i); if (ACPI_FAILURE (Status)) { @@ -629,7 +653,7 @@ AcpiNsCheckPackage ( { /* These are the required package elements (0, 1, or 2) */ - Status = AcpiNsCheckObjectType (Pathname, Elements, + Status = AcpiNsCheckObjectType (Data, Elements, Package->RetInfo3.ObjectType[i], i); if (ACPI_FAILURE (Status)) { @@ -640,7 +664,7 @@ AcpiNsCheckPackage ( { /* These are the optional package elements */ - Status = AcpiNsCheckObjectType (Pathname, Elements, + Status = AcpiNsCheckObjectType (Data, Elements, Package->RetInfo3.TailObjectType, i); if (ACPI_FAILURE (Status)) { @@ -652,11 +676,31 @@ AcpiNsCheckPackage ( break; + case ACPI_PTYPE2_REV_FIXED: + + /* First element is the (Integer) revision */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Elements++; + Count--; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + case ACPI_PTYPE2_PKG_COUNT: /* First element is the (Integer) count of sub-packages to follow */ - Status = AcpiNsCheckObjectType (Pathname, Elements, + Status = AcpiNsCheckObjectType (Data, Elements, ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { @@ -676,9 +720,10 @@ AcpiNsCheckPackage ( Count = ExpectedCount; Elements++; - /* Now we can walk the sub-packages */ + /* Examine the sub-packages */ - /*lint -fallthrough */ + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; case ACPI_PTYPE2: @@ -687,147 +732,249 @@ AcpiNsCheckPackage ( case ACPI_PTYPE2_COUNT: /* - * These types all return a single package that consists of a variable - * number of sub-packages + * These types all return a single Package that consists of a + * variable number of sub-Packages. + * + * First, ensure that the first element is a sub-Package. If not, + * the BIOS may have incorrectly returned the object as a single + * package instead of a Package of Packages (a common error if + * there is only one entry). We may be able to repair this by + * wrapping the returned Package with a new outer Package. */ - for (i = 0; i < Count; i++) + if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)) { - SubPackage = *Elements; - SubElements = SubPackage->Package.Elements; + /* Create the new outer package and populate it */ - /* Each sub-object must be of type Package */ - - Status = AcpiNsCheckObjectType (Pathname, &SubPackage, - ACPI_RTYPE_PACKAGE, i); + Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr); if (ACPI_FAILURE (Status)) { return (Status); } - /* Examine the different types of sub-packages */ + /* Update locals to point to the new package (of 1 element) */ - switch (Package->RetInfo.Type) - { - case ACPI_PTYPE2: - case ACPI_PTYPE2_PKG_COUNT: + ReturnObject = *ReturnObjectPtr; + Elements = ReturnObject->Package.Elements; + Count = 1; + } - /* Each subpackage has a fixed number of elements */ + /* Examine the sub-packages */ - ExpectedCount = - Package->RetInfo.Count1 + Package->RetInfo.Count2; - if (SubPackage->Package.Count != ExpectedCount) - { - Count = SubPackage->Package.Count; - goto PackageTooSmall; - } + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; - Status = AcpiNsCheckPackageElements (Pathname, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; - case ACPI_PTYPE2_FIXED: + default: - /* Each sub-package has a fixed length */ + /* Should not get here if predefined info table is correct */ - ExpectedCount = Package->RetInfo2.Count; - if (SubPackage->Package.Count < ExpectedCount) - { - Count = SubPackage->Package.Count; - goto PackageTooSmall; - } + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid internal return type in table entry: %X", + Package->RetInfo.Type)); - /* Check the type of each sub-package element */ + return (AE_AML_INTERNAL); + } - for (j = 0; j < ExpectedCount; j++) - { - Status = AcpiNsCheckObjectType (Pathname, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - break; + return (Status); - case ACPI_PTYPE2_MIN: - /* Each sub-package has a variable but minimum length */ +PackageTooSmall: - ExpectedCount = Package->RetInfo.Count1; - if (SubPackage->Package.Count < ExpectedCount) - { - Count = SubPackage->Package.Count; - goto PackageTooSmall; - } + /* Error exit for the case with an incorrect package count */ - /* Check the type of each sub-package element */ + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); - Status = AcpiNsCheckPackageElements (Pathname, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - break; + return (AE_AML_OPERAND_VALUE); +} - case ACPI_PTYPE2_COUNT: - /* First element is the (Integer) count of elements to follow */ +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * Package - Pointer to package-specific info for method + * Elements - Element list of parent package. All elements + * of this list should be of type Package. + * Count - Count of subpackages + * + * RETURN: Status + * + * DESCRIPTION: Examine a list of subpackages + * + ******************************************************************************/ - Status = AcpiNsCheckObjectType (Pathname, SubElements, - ACPI_RTYPE_INTEGER, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *SubPackage; + ACPI_OPERAND_OBJECT **SubElements; + ACPI_STATUS Status; + UINT32 ExpectedCount; + UINT32 i; + UINT32 j; - /* Make sure package is large enough for the Count */ - ExpectedCount = (UINT32) (*SubElements)->Integer.Value; - if (SubPackage->Package.Count < ExpectedCount) - { - Count = SubPackage->Package.Count; - goto PackageTooSmall; - } + /* + * Validate each sub-Package in the parent Package + * + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + for (i = 0; i < Count; i++) + { + SubPackage = *Elements; + SubElements = SubPackage->Package.Elements; + Data->ParentPackage = SubPackage; + + /* Each sub-object must be of type Package */ + + Status = AcpiNsCheckObjectType (Data, &SubPackage, + ACPI_RTYPE_PACKAGE, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - /* Check the type of each sub-package element */ + /* Examine the different types of expected sub-packages */ - Status = AcpiNsCheckPackageElements (Pathname, - (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); + Data->ParentPackage = SubPackage; + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE2: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_REV_FIXED: + + /* Each subpackage has a fixed number of elements */ + + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_FIXED: + + /* Each sub-package has a fixed length */ + + ExpectedCount = Package->RetInfo2.Count; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + for (j = 0; j < ExpectedCount; j++) + { + Status = AcpiNsCheckObjectType (Data, &SubElements[j], + Package->RetInfo2.ObjectType[j], j); if (ACPI_FAILURE (Status)) { return (Status); } - break; + } + break; + + + case ACPI_PTYPE2_MIN: - default: - break; + /* Each sub-package has a variable but minimum length */ + + ExpectedCount = Package->RetInfo.Count1; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; } - Elements++; - } - break; + /* Check the type of each sub-package element */ + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; - default: - /* Should not get here if predefined info table is correct */ + case ACPI_PTYPE2_COUNT: + + /* + * First element is the (Integer) count of elements, including + * the count field (the ACPI name is NumElements) + */ + Status = AcpiNsCheckObjectType (Data, SubElements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - ACPI_WARNING ((AE_INFO, - "%s: Invalid internal return type in table entry: %X", - Pathname, Package->RetInfo.Type)); + /* + * Make sure package is large enough for the Count and is + * is as large as the minimum size + */ + ExpectedCount = (UINT32) (*SubElements)->Integer.Value; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + if (SubPackage->Package.Count < Package->RetInfo.Count1) + { + ExpectedCount = Package->RetInfo.Count1; + goto PackageTooSmall; + } + if (ExpectedCount == 0) + { + /* + * Either the NumEntries element was originally zero or it was + * a NULL element and repaired to an Integer of value zero. + * In either case, repair it by setting NumEntries to be the + * actual size of the subpackage. + */ + ExpectedCount = SubPackage->Package.Count; + (*SubElements)->Integer.Value = ExpectedCount; + } - return (AE_AML_INTERNAL); + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, (SubElements + 1), + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + default: /* Should not get here, type was validated by caller */ + + return (AE_AML_INTERNAL); + } + + Elements++; } return (AE_OK); @@ -835,10 +982,11 @@ AcpiNsCheckPackage ( PackageTooSmall: - /* Error exit for the case with an incorrect package count */ + /* The sub-package count was smaller than required */ - ACPI_WARNING ((AE_INFO, "%s: Return Package is too small - " - "found %u, expected %u", Pathname, Count, ExpectedCount)); + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Sub-Package[%u] is too small - found %u elements, expected %u", + i, SubPackage->Package.Count, ExpectedCount)); return (AE_AML_OPERAND_VALUE); } @@ -848,7 +996,7 @@ PackageTooSmall: * * FUNCTION: AcpiNsCheckPackageElements * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * PARAMETERS: Data - Pointer to validation data structure * Elements - Pointer to the package elements array * Type1 - Object type for first group * Count1 - Count for first group @@ -865,7 +1013,7 @@ PackageTooSmall: static ACPI_STATUS AcpiNsCheckPackageElements ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **Elements, UINT8 Type1, UINT32 Count1, @@ -885,7 +1033,7 @@ AcpiNsCheckPackageElements ( */ for (i = 0; i < Count1; i++) { - Status = AcpiNsCheckObjectType (Pathname, ThisElement, + Status = AcpiNsCheckObjectType (Data, ThisElement, Type1, i + StartIndex); if (ACPI_FAILURE (Status)) { @@ -896,7 +1044,7 @@ AcpiNsCheckPackageElements ( for (i = 0; i < Count2; i++) { - Status = AcpiNsCheckObjectType (Pathname, ThisElement, + Status = AcpiNsCheckObjectType (Data, ThisElement, Type2, (i + Count1 + StartIndex)); if (ACPI_FAILURE (Status)) { @@ -913,12 +1061,13 @@ AcpiNsCheckPackageElements ( * * FUNCTION: AcpiNsCheckObjectType * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * PARAMETERS: Data - Pointer to validation data structure * ReturnObjectPtr - Pointer to the object returned from the * evaluation of a method or object * ExpectedBtypes - Bitmap of expected return type(s) * PackageIndex - Index of object within parent package (if - * applicable - ACPI_NOT_PACKAGE otherwise) + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) * * RETURN: Status * @@ -929,7 +1078,7 @@ AcpiNsCheckPackageElements ( static ACPI_STATUS AcpiNsCheckObjectType ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex) @@ -938,17 +1087,22 @@ AcpiNsCheckObjectType ( ACPI_STATUS Status = AE_OK; UINT32 ReturnBtype; char TypeBuffer[48]; /* Room for 5 types */ - UINT32 ThisRtype; - UINT32 i; - UINT32 j; /* - * If we get a NULL ReturnObject here, it is a NULL package element, - * and this is always an error. + * If we get a NULL ReturnObject here, it is a NULL package element. + * Since all extraneous NULL package elements were removed earlier by a + * call to AcpiNsRemoveNullElements, this is an unexpected NULL element. + * We will attempt to repair it. */ if (!ReturnObject) { + Status = AcpiNsRepairNullElement (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } goto TypeErrorExit; } @@ -956,9 +1110,9 @@ AcpiNsCheckObjectType ( if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) { - ACPI_WARNING ((AE_INFO, - "%s: Invalid return type - Found a Namespace node [%4.4s] type %s", - Pathname, ReturnObject->Node.Name.Ascii, + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid return type - Found a Namespace node [%4.4s] type %s", + ReturnObject->Node.Name.Ascii, AcpiUtGetTypeName (ReturnObject->Node.Type))); return (AE_AML_OPERAND_TYPE); } @@ -1001,60 +1155,45 @@ AcpiNsCheckObjectType ( /* Is the object one of the expected types? */ - if (!(ReturnBtype & ExpectedBtypes)) + if (ReturnBtype & ExpectedBtypes) { - /* Type mismatch -- attempt repair of the returned object */ + /* For reference objects, check that the reference type is correct */ - Status = AcpiNsRepairObject (ExpectedBtypes, PackageIndex, - ReturnObjectPtr); - if (ACPI_SUCCESS (Status)) + if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) { - return (Status); + Status = AcpiNsCheckReference (Data, ReturnObject); } - goto TypeErrorExit; + + return (Status); } - /* For reference objects, check that the reference type is correct */ + /* Type mismatch -- attempt repair of the returned object */ - if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + Status = AcpiNsRepairObject (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) { - Status = AcpiNsCheckReference (Pathname, ReturnObject); + return (AE_OK); /* Repair was successful */ } - return (Status); - TypeErrorExit: /* Create a string with all expected types for this predefined object */ - j = 1; - TypeBuffer[0] = 0; - ThisRtype = ACPI_RTYPE_INTEGER; + AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); - for (i = 0; i < ACPI_NUM_RTYPES; i++) + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { - /* If one of the expected types, concatenate the name of this type */ - - if (ExpectedBtypes & ThisRtype) - { - ACPI_STRCAT (TypeBuffer, &AcpiRtypeNames[i][j]); - j = 0; /* Use name separator from now on */ - } - ThisRtype <<= 1; /* Next Rtype */ - } - - if (PackageIndex == ACPI_NOT_PACKAGE) - { - ACPI_WARNING ((AE_INFO, - "%s: Return type mismatch - found %s, expected %s", - Pathname, AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - found %s, expected %s", + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } else { - ACPI_WARNING ((AE_INFO, - "%s: Return Package type mismatch at index %u - " - "found %s, expected %s", Pathname, PackageIndex, + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package type mismatch at index %u - " + "found %s, expected %s", PackageIndex, AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); } @@ -1066,7 +1205,7 @@ TypeErrorExit: * * FUNCTION: AcpiNsCheckReference * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * PARAMETERS: Data - Pointer to validation data structure * ReturnObject - Object returned from the evaluation of a * method or object * @@ -1080,7 +1219,7 @@ TypeErrorExit: static ACPI_STATUS AcpiNsCheckReference ( - char *Pathname, + ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT *ReturnObject) { @@ -1094,10 +1233,9 @@ AcpiNsCheckReference ( return (AE_OK); } - ACPI_WARNING ((AE_INFO, - "%s: Return type mismatch - " - "unexpected reference object type [%s] %2.2X", - Pathname, AcpiUtGetReferenceName (ReturnObject), + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - unexpected reference object type [%s] %2.2X", + AcpiUtGetReferenceName (ReturnObject), ReturnObject->Reference.Class)); return (AE_AML_OPERAND_TYPE); @@ -1106,91 +1244,41 @@ AcpiNsCheckReference ( /******************************************************************************* * - * FUNCTION: AcpiNsRepairObject + * FUNCTION: AcpiNsGetExpectedTypes * - * PARAMETERS: Pathname - Full pathname to the node (for error msgs) - * PackageIndex - Used to determine if target is in a package - * ReturnObjectPtr - Pointer to the object returned from the - * evaluation of a method or object + * PARAMETERS: Buffer - Pointer to where the string is returned + * ExpectedBtypes - Bitmap of expected return type(s) * - * RETURN: Status. AE_OK if repair was successful. + * RETURN: Buffer is populated with type names. * - * DESCRIPTION: Attempt to repair/convert a return object of a type that was - * not expected. + * DESCRIPTION: Translate the expected types bitmap into a string of ascii + * names of expected types, for use in warning messages. * ******************************************************************************/ -static ACPI_STATUS -AcpiNsRepairObject ( - UINT32 ExpectedBtypes, - UINT32 PackageIndex, - ACPI_OPERAND_OBJECT **ReturnObjectPtr) +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) { - ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; - ACPI_OPERAND_OBJECT *NewObject; - ACPI_SIZE Length; - - - switch (ReturnObject->Common.Type) - { - case ACPI_TYPE_BUFFER: - - if (!(ExpectedBtypes & ACPI_RTYPE_STRING)) - { - return (AE_AML_OPERAND_TYPE); - } - - /* - * Have a Buffer, expected a String, convert. Use a ToString - * conversion, no transform performed on the buffer data. The best - * example of this is the _BIF method, where the string data from - * the battery is often (incorrectly) returned as buffer object(s). - */ - Length = 0; - while ((Length < ReturnObject->Buffer.Length) && - (ReturnObject->Buffer.Pointer[Length])) - { - Length++; - } - - /* Allocate a new string object */ - - NewObject = AcpiUtCreateStringObject (Length); - if (!NewObject) - { - return (AE_NO_MEMORY); - } + UINT32 ThisRtype; + UINT32 i; + UINT32 j; - /* - * Copy the raw buffer data with no transform. String is already NULL - * terminated at Length+1. - */ - ACPI_MEMCPY (NewObject->String.Pointer, - ReturnObject->Buffer.Pointer, Length); - /* Install the new return object */ + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; - AcpiUtRemoveReference (ReturnObject); - *ReturnObjectPtr = NewObject; + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ - /* - * If the object is a package element, we need to: - * 1. Decrement the reference count of the orignal object, it was - * incremented when building the package - * 2. Increment the reference count of the new object, it will be - * decremented when releasing the package - */ - if (PackageIndex != ACPI_NOT_PACKAGE) + if (ExpectedBtypes & ThisRtype) { - AcpiUtRemoveReference (ReturnObject); - AcpiUtAddReference (NewObject); + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ } - return (AE_OK); - - default: - break; + ThisRtype <<= 1; /* Next Rtype */ } - - return (AE_AML_OPERAND_TYPE); } - diff --git a/sys/contrib/dev/acpica-unix/namespace/nsrepair.c b/sys/contrib/dev/acpica-unix/namespace/nsrepair.c new file mode 100644 index 0000000000..7b93595bb9 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/namespace/nsrepair.c @@ -0,0 +1,876 @@ +/****************************************************************************** + * + * Module Name: nsrepair - Repair for objects returned by predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acpredef.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair") + + +/******************************************************************************* + * + * This module attempts to repair or convert objects returned by the + * predefined methods to an object type that is expected, as per the ACPI + * specification. The need for this code is dictated by the many machines that + * return incorrect types for the standard predefined methods. Performing these + * conversions here, in one place, eliminates the need for individual ACPI + * device drivers to do the same. Note: Most of these conversions are different + * than the internal object conversion routines used for implicit object + * conversion. + * + * The following conversions can be performed as necessary: + * + * Integer -> String + * Integer -> Buffer + * String -> Integer + * String -> Buffer + * Buffer -> Integer + * Buffer -> String + * Buffer -> Package of Integers + * Package -> Package of one Package + * + * Additional possible repairs: + * + * Optional/unnecessary NULL package elements removed + * Required package elements that are NULL replaced by Integer/String/Buffer + * Incorrect standalone package wrapped with required outer package + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairObject + * + * PARAMETERS: Data - Pointer to validation data structure + * ExpectedBtypes - Object types expected + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsRepairObject); + + + /* + * At this point, we know that the type of the returned object was not + * one of the expected types for this predefined name. Attempt to + * repair the object by converting it to one of the expected object + * types for this predefined name. + */ + if (ExpectedBtypes & ACPI_RTYPE_INTEGER) + { + Status = AcpiNsConvertToInteger (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_STRING) + { + Status = AcpiNsConvertToString (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_BUFFER) + { + Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + Status = AcpiNsConvertToPackage (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + + /* We cannot repair this object */ + + return (AE_AML_OPERAND_TYPE); + + +ObjectRepaired: + + /* Object was successfully repaired */ + + /* + * If the original object is a package element, we need to: + * 1. Set the reference count of the new object to match the + * reference count of the old object. + * 2. Decrement the reference count of the original object. + */ + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + NewObject->Common.ReferenceCount = + ReturnObject->Common.ReferenceCount; + + if (ReturnObject->Common.ReferenceCount > 1) + { + ReturnObject->Common.ReferenceCount--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s at index %u\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject))); + } + + /* Delete old object, install the new return object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = NewObject; + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToInteger + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + UINT64 Value = 0; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + /* String-to-Integer conversion */ + + Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, + ACPI_ANY_BASE, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ + + if (OriginalObject->Buffer.Length > 8) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Extract each buffer byte to create the integer */ + + for (i = 0; i < OriginalObject->Buffer.Length; i++) + { + Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8)); + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + NewObject = AcpiUtCreateIntegerObject (Value); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToString + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_SIZE Length; + ACPI_STATUS Status; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-String conversion. Commonly, convert + * an integer of value 0 to a NULL string. The last element of + * _BIF and _BIX packages occasionally need this fix. + */ + if (OriginalObject->Integer.Value == 0) + { + /* Allocate a new NULL string object */ + + NewObject = AcpiUtCreateStringObject (0); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + } + else + { + Status = AcpiExConvertToString (OriginalObject, &NewObject, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + case ACPI_TYPE_BUFFER: + /* + * Buffer-to-String conversion. Use a ToString + * conversion, no transform performed on the buffer data. The best + * example of this is the _BIF method, where the string data from + * the battery is often (incorrectly) returned as buffer object(s). + */ + Length = 0; + while ((Length < OriginalObject->Buffer.Length) && + (OriginalObject->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + NewObject = AcpiUtCreateStringObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* + * Copy the raw buffer data with no transform. String is already NULL + * terminated at Length+1. + */ + ACPI_MEMCPY (NewObject->String.Pointer, + OriginalObject->Buffer.Pointer, Length); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToBuffer + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Elements; + UINT32 *DwordBuffer; + UINT32 Count; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-Buffer conversion. + * Convert the Integer to a packed-byte buffer. _MAT and other + * objects need this sometimes, if a read has been performed on a + * Field object that is less than or equal to the global integer + * size (32 or 64 bits). + */ + Status = AcpiExConvertToBuffer (OriginalObject, &NewObject); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_STRING: + + /* String-to-Buffer conversion. Simple data copy */ + + NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (NewObject->Buffer.Pointer, + OriginalObject->String.Pointer, OriginalObject->String.Length); + break; + + case ACPI_TYPE_PACKAGE: + /* + * This case is often seen for predefined names that must return a + * Buffer object with multiple DWORD integers within. For example, + * _FDE and _GTM. The Package can be converted to a Buffer. + */ + + /* All elements of the Package must be integers */ + + Elements = OriginalObject->Package.Elements; + Count = OriginalObject->Package.Count; + + for (i = 0; i < Count; i++) + { + if ((!*Elements) || + ((*Elements)->Common.Type != ACPI_TYPE_INTEGER)) + { + return (AE_AML_OPERAND_TYPE); + } + Elements++; + } + + /* Create the new buffer object to replace the Package */ + + NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count)); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Copy the package elements (integers) to the buffer as DWORDs */ + + Elements = OriginalObject->Package.Elements; + DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer); + + for (i = 0; i < Count; i++) + { + *DwordBuffer = (UINT32) (*Elements)->Integer.Value; + DwordBuffer++; + Elements++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToPackage + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of + * the buffer is converted to a single integer package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_OPERAND_OBJECT **Elements; + UINT32 Length; + UINT8 *Buffer; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Package conversion */ + + Length = OriginalObject->Buffer.Length; + NewObject = AcpiUtCreatePackageObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Convert each buffer byte to an integer package element */ + + Elements = NewObject->Package.Elements; + Buffer = OriginalObject->Buffer.Pointer; + + while (Length--) + { + *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer); + if (!*Elements) + { + AcpiUtRemoveReference (NewObject); + return (AE_NO_MEMORY); + } + Elements++; + Buffer++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairNullElement + * + * PARAMETERS: Data - Pointer to validation data structure + * ExpectedBtypes - Object types expected + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. + * + * DESCRIPTION: Attempt to repair a NULL element of a returned Package object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairNullElement ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewObject; + + + ACPI_FUNCTION_NAME (NsRepairNullElement); + + + /* No repair needed if return object is non-NULL */ + + if (ReturnObject) + { + return (AE_OK); + } + + /* + * Attempt to repair a NULL element of a Package object. This applies to + * predefined names that return a fixed-length package and each element + * is required. It does not apply to variable-length packages where NULL + * elements are allowed, especially at the end of the package. + */ + if (ExpectedBtypes & ACPI_RTYPE_INTEGER) + { + /* Need an Integer - create a zero-value integer */ + + NewObject = AcpiUtCreateIntegerObject ((UINT64) 0); + } + else if (ExpectedBtypes & ACPI_RTYPE_STRING) + { + /* Need a String - create a NULL string */ + + NewObject = AcpiUtCreateStringObject (0); + } + else if (ExpectedBtypes & ACPI_RTYPE_BUFFER) + { + /* Need a Buffer - create a zero-length buffer */ + + NewObject = AcpiUtCreateBufferObject (0); + } + else + { + /* Error for all other expected types */ + + return (AE_AML_OPERAND_TYPE); + } + + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Set the reference count according to the parent Package object */ + + NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted NULL package element to expected %s at index %u\n", + Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + + *ReturnObjectPtr = NewObject; + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRemoveNullElements + * + * PARAMETERS: Data - Pointer to validation data structure + * PackageType - An AcpiReturnPackageTypes value + * ObjDesc - A Package object + * + * RETURN: None. + * + * DESCRIPTION: Remove all NULL package elements from packages that contain + * a variable number of sub-packages. For these types of + * packages, NULL elements can be safely removed. + * + *****************************************************************************/ + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT **Source; + ACPI_OPERAND_OBJECT **Dest; + UINT32 Count; + UINT32 NewCount; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRemoveNullElements); + + + /* + * PTYPE1 packages contain no subpackages. + * PTYPE2 packages contain a variable number of sub-packages. We can + * safely remove all NULL elements from the PTYPE2 packages. + */ + switch (PackageType) + { + case ACPI_PTYPE1_FIXED: + case ACPI_PTYPE1_VAR: + case ACPI_PTYPE1_OPTION: + return; + + case ACPI_PTYPE2: + case ACPI_PTYPE2_COUNT: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_REV_FIXED: + break; + + default: + return; + } + + Count = ObjDesc->Package.Count; + NewCount = Count; + + Source = ObjDesc->Package.Elements; + Dest = Source; + + /* Examine all elements of the package object, remove nulls */ + + for (i = 0; i < Count; i++) + { + if (!*Source) + { + NewCount--; + } + else + { + *Dest = *Source; + Dest++; + } + Source++; + } + + /* Update parent package if any null elements were removed */ + + if (NewCount < Count) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Found and removed %u NULL elements\n", + Data->Pathname, (Count - NewCount))); + + /* NULL terminate list and update the package count */ + + *Dest = NULL; + ObjDesc->Package.Count = NewCount; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * ObjDescPtr - Pointer to the object to repair. The new + * package object is returned here, + * overwriting the old object. + * + * RETURN: Status, new object in *ObjDescPtr + * + * DESCRIPTION: Repair a common problem with objects that are defined to return + * a variable-length Package of Packages. If the variable-length + * is one, some BIOS code mistakenly simply declares a single + * Package instead of a Package with one sub-Package. This + * function attempts to repair this error by wrapping a Package + * object around the original Package, creating the correct + * Package with one sub-Package. + * + * Names that can be repaired in this manner include: + * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *PkgObjDesc; + + + ACPI_FUNCTION_NAME (NsRepairPackageList); + + + /* + * Create the new outer package and populate it. The new package will + * have a single element, the lone subpackage. + */ + PkgObjDesc = AcpiUtCreatePackageObject (1); + if (!PkgObjDesc) + { + return (AE_NO_MEMORY); + } + + PkgObjDesc->Package.Elements[0] = *ObjDescPtr; + + /* Return the new object in the object pointer */ + + *ObjDescPtr = PkgObjDesc; + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired incorrectly formed Package\n", Data->Pathname)); + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/namespace/nsrepair2.c b/sys/contrib/dev/acpica-unix/namespace/nsrepair2.c new file mode 100644 index 0000000000..82017411b4 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/namespace/nsrepair2.c @@ -0,0 +1,883 @@ +/****************************************************************************** + * + * Module Name: nsrepair2 - Repair for objects returned by specific + * predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair2") + + +/* + * Information structure and handler for ACPI predefined names that can + * be repaired on a per-name basis. + */ +typedef +ACPI_STATUS (*ACPI_REPAIR_FUNCTION) ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +typedef struct acpi_repair_info +{ + char Name[ACPI_NAME_SIZE]; + ACPI_REPAIR_FUNCTION RepairFunction; + +} ACPI_REPAIR_INFO; + + +/* Local prototypes */ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node); + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_CID ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_HID ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName); + +static void +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection); + +/* Values for SortDirection above */ + +#define ACPI_SORT_ASCENDING 0 +#define ACPI_SORT_DESCENDING 1 + + +/* + * This table contains the names of the predefined methods for which we can + * perform more complex repairs. + * + * As necessary: + * + * _ALR: Sort the list ascending by AmbientIlluminance + * _CID: Strings: uppercase all, remove any leading asterisk + * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs + * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs + * _HID: Strings: uppercase all, remove any leading asterisk + * _PSS: Sort the list descending by Power + * _TSS: Sort the list descending by Power + * + * Names that must be packages, but cannot be sorted: + * + * _BCL: Values are tied to the Package index where they appear, and cannot + * be moved or sorted. These index values are used for _BQC and _BCM. + * However, we can fix the case where a buffer is returned, by converting + * it to a Package of integers. + */ +static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] = +{ + {"_ALR", AcpiNsRepair_ALR}, + {"_CID", AcpiNsRepair_CID}, + {"_FDE", AcpiNsRepair_FDE}, + {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */ + {"_HID", AcpiNsRepair_HID}, + {"_PSS", AcpiNsRepair_PSS}, + {"_TSS", AcpiNsRepair_TSS}, + {{0,0,0,0}, NULL} /* Table terminator */ +}; + + +#define ACPI_FDE_FIELD_COUNT 5 +#define ACPI_FDE_BYTE_BUFFER_SIZE 5 +#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32)) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsComplexRepairs + * + * PARAMETERS: Data - Pointer to validation data structure + * Node - Namespace node for the method/object + * ValidateStatus - Original status of earlier validation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. If name is not + * matched, ValidateStatus is returned. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + const ACPI_REPAIR_INFO *Predefined; + ACPI_STATUS Status; + + + /* Check if this name is in the list of repairable names */ + + Predefined = AcpiNsMatchRepairableName (Node); + if (!Predefined) + { + return (ValidateStatus); + } + + Status = Predefined->RepairFunction (Data, ReturnObjectPtr); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsMatchRepairableName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in repair table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the repairable object list. + * + *****************************************************************************/ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_REPAIR_INFO *ThisName; + + + /* Search info table for a repairable predefined method/object name */ + + ThisName = AcpiNsRepairableNames; + while (ThisName->RepairFunction) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name)) + { + return (ThisName); + } + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_ALR + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list + * ascending by the ambient illuminance values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1, + ACPI_SORT_ASCENDING, "AmbientIlluminance"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_FDE + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return + * value is a Buffer of 5 DWORDs. This function repairs a common + * problem where the return value is a Buffer of BYTEs, not + * DWORDs. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *BufferObject; + UINT8 *ByteBuffer; + UINT32 *DwordBuffer; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRepair_FDE); + + + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* This is the expected type. Length should be (at least) 5 DWORDs */ + + if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE) + { + return (AE_OK); + } + + /* We can only repair if we have exactly 5 BYTEs */ + + if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Incorrect return buffer length %u, expected %u", + ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); + + return (AE_AML_OPERAND_TYPE); + } + + /* Create the new (larger) buffer object */ + + BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE); + if (!BufferObject) + { + return (AE_NO_MEMORY); + } + + /* Expand each byte to a DWORD */ + + ByteBuffer = ReturnObject->Buffer.Pointer; + DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer); + + for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) + { + *DwordBuffer = (UINT32) *ByteBuffer; + DwordBuffer++; + ByteBuffer++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s Expanded Byte Buffer to expected DWord Buffer\n", + Data->Pathname)); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + /* Delete the original return object, return the new buffer object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = BufferObject; + + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_CID + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _CID object. If a string, ensure that all + * letters are uppercase and that there is no leading asterisk. + * If a Package, ensure same for all string elements. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_CID ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT **ElementPtr; + ACPI_OPERAND_OBJECT *OriginalElement; + UINT16 OriginalRefCount; + UINT32 i; + + + /* Check for _CID as a simple string */ + + if (ReturnObject->Common.Type == ACPI_TYPE_STRING) + { + Status = AcpiNsRepair_HID (Data, ReturnObjectPtr); + return (Status); + } + + /* Exit if not a Package */ + + if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_OK); + } + + /* Examine each element of the _CID package */ + + ElementPtr = ReturnObject->Package.Elements; + for (i = 0; i < ReturnObject->Package.Count; i++) + { + OriginalElement = *ElementPtr; + OriginalRefCount = OriginalElement->Common.ReferenceCount; + + Status = AcpiNsRepair_HID (Data, ElementPtr); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Take care with reference counts */ + + if (OriginalElement != *ElementPtr) + { + /* Element was replaced */ + + (*ElementPtr)->Common.ReferenceCount = + OriginalRefCount; + + AcpiUtRemoveReference (OriginalElement); + } + + ElementPtr++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_HID + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _HID object. If a string, ensure that all + * letters are uppercase and that there is no leading asterisk. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_HID ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewString; + char *Source; + char *Dest; + + + ACPI_FUNCTION_NAME (NsRepair_HID); + + + /* We only care about string _HID objects (not integers) */ + + if (ReturnObject->Common.Type != ACPI_TYPE_STRING) + { + return (AE_OK); + } + + if (ReturnObject->String.Length == 0) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid zero-length _HID or _CID string")); + + /* Return AE_OK anyway, let driver handle it */ + + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); + } + + /* It is simplest to always create a new string object */ + + NewString = AcpiUtCreateStringObject (ReturnObject->String.Length); + if (!NewString) + { + return (AE_NO_MEMORY); + } + + /* + * Remove a leading asterisk if present. For some unknown reason, there + * are many machines in the field that contains IDs like this. + * + * Examples: "*PNP0C03", "*ACPI0003" + */ + Source = ReturnObject->String.Pointer; + if (*Source == '*') + { + Source++; + NewString->String.Length--; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Removed invalid leading asterisk\n", Data->Pathname)); + } + + /* + * Copy and uppercase the string. From the ACPI specification: + * + * A valid PNP ID must be of the form "AAA####" where A is an uppercase + * letter and # is a hex digit. A valid ACPI ID must be of the form + * "ACPI####" where # is a hex digit. + */ + for (Dest = NewString->String.Pointer; *Source; Dest++, Source++) + { + *Dest = (char) ACPI_TOUPPER (*Source); + } + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = NewString; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_TSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list + * descending by the power dissipation values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1, + ACPI_SORT_DESCENDING, "PowerDissipation"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_PSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list + * by the CPU frequencies. Check that the power dissipation values + * are all proportional to CPU frequency (i.e., sorting by + * frequency should be the same as sorting by power.) + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT **OuterElements; + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 PreviousValue; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Entries (sub-packages) in the _PSS Package must be sorted by power + * dissipation, in descending order. If it appears that the list is + * incorrectly sorted, sort it. We sort by CpuFrequency, since this + * should be proportional to the power. + */ + Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0, + ACPI_SORT_DESCENDING, "CpuFrequency"); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * We now know the list is correctly sorted by CPU frequency. Check if + * the power dissipation values are proportional. + */ + PreviousValue = ACPI_UINT32_MAX; + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + + for (i = 0; i < OuterElementCount; i++) + { + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[1]; /* Index1 = PowerDissipation */ + + if ((UINT32) ObjDesc->Integer.Value > PreviousValue) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "SubPackage[%u,%u] - suspicious power dissipation values", + i-1, i)); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCheckSortedList + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Pointer to the top-level returned object + * ExpectedCount - Minimum length of each sub-package + * SortIndex - Sub-package entry to sort on + * SortDirection - Ascending or descending + * SortKeyName - Name of the SortIndex field + * + * RETURN: Status. AE_OK if the list is valid and is sorted correctly or + * has been repaired by sorting the list. + * + * DESCRIPTION: Check if the package list is valid and sorted correctly by the + * SortIndex. If not, then sort the list. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName) +{ + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **OuterElements; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + UINT32 PreviousValue; + + + ACPI_FUNCTION_NAME (NsCheckSortedList); + + + /* The top-level object must be a package */ + + if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + if (!OuterElementCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + PreviousValue = 0; + if (SortDirection == ACPI_SORT_DESCENDING) + { + PreviousValue = ACPI_UINT32_MAX; + } + + /* Examine each subpackage */ + + for (i = 0; i < OuterElementCount; i++) + { + /* Each element of the top-level package must also be a package */ + + if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must have the minimum length */ + + if ((*OuterElements)->Package.Count < ExpectedCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[SortIndex]; + + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * The list must be sorted in the specified order. If we detect a + * discrepancy, sort the entire list. + */ + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc->Integer.Value < PreviousValue)) || + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc->Integer.Value > PreviousValue))) + { + AcpiNsSortList (ReturnObject->Package.Elements, + OuterElementCount, SortIndex, SortDirection); + + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired unsorted list - now sorted by %s\n", + Data->Pathname, SortKeyName)); + return (AE_OK); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsSortList + * + * PARAMETERS: Elements - Package object element list + * Count - Element count for above + * Index - Sort by which package element + * SortDirection - Ascending or Descending sort + * + * RETURN: None + * + * DESCRIPTION: Sort the objects that are in a package element list. + * + * NOTE: Assumes that all NULL elements have been removed from the package, + * and that all elements have been verified to be of type Integer. + * + *****************************************************************************/ + +static void +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection) +{ + ACPI_OPERAND_OBJECT *ObjDesc1; + ACPI_OPERAND_OBJECT *ObjDesc2; + ACPI_OPERAND_OBJECT *TempObj; + UINT32 i; + UINT32 j; + + + /* Simple bubble sort */ + + for (i = 1; i < Count; i++) + { + for (j = (Count - 1); j >= i; j--) + { + ObjDesc1 = Elements[j-1]->Package.Elements[Index]; + ObjDesc2 = Elements[j]->Package.Elements[Index]; + + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) || + + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value))) + { + TempObj = Elements[j-1]; + Elements[j-1] = Elements[j]; + Elements[j] = TempObj; + } + } + } +} diff --git a/sys/contrib/dev/acpica-unix/namespace/nssearch.c b/sys/contrib/dev/acpica-unix/namespace/nssearch.c index fce7c5ad4d..c1ba96ede5 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nssearch.c +++ b/sys/contrib/dev/acpica-unix/namespace/nssearch.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -229,17 +229,6 @@ AcpiNsSearchOneScope ( 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 (Node->Flags & ANOBJ_END_OF_PEER_LIST) - { - /* Searched entire list, we are done */ - - break; - } - /* Didn't match name, move on to the next peer object */ Node = Node->Peer; @@ -296,7 +285,7 @@ AcpiNsSearchParentTree ( ACPI_FUNCTION_TRACE (NsSearchParentTree); - ParentNode = AcpiNsGetParentNode (Node); + ParentNode = Node->Parent; /* * If there is no parent (i.e., we are at the root) or type is "local", @@ -341,7 +330,7 @@ AcpiNsSearchParentTree ( /* Not found here, go up another level (until we reach the root) */ - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; } /* Not found in parent tree */ @@ -397,7 +386,7 @@ AcpiNsSearchAndEnter ( if (!Node || !TargetName || !ReturnNode) { ACPI_ERROR ((AE_INFO, - "Null parameter: Node %p Name %X ReturnNode %p", + "Null parameter: Node %p Name 0x%X ReturnNode %p", Node, TargetName, ReturnNode)); return_ACPI_STATUS (AE_BAD_PARAMETER); } diff --git a/sys/contrib/dev/acpica-unix/namespace/nsutils.c b/sys/contrib/dev/acpica-unix/namespace/nsutils.c index 4bfb7c38c1..603a00ffe7 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsutils.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsutils.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -137,118 +137,6 @@ AcpiNsFindParentName ( #endif -/******************************************************************************* - * - * FUNCTION: AcpiNsReportError - * - * PARAMETERS: ModuleName - Caller's module name (for error output) - * LineNumber - Caller's line number (for error output) - * InternalName - Name or path of the namespace node - * LookupStatus - Exception code from NS lookup - * - * RETURN: None - * - * DESCRIPTION: Print warning message with full pathname - * - ******************************************************************************/ - -void -AcpiNsReportError ( - const char *ModuleName, - UINT32 LineNumber, - const char *InternalName, - ACPI_STATUS LookupStatus) -{ - ACPI_STATUS Status; - UINT32 BadName; - char *Name = NULL; - - - AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); - - if (LookupStatus == AE_BAD_CHARACTER) - { - /* There is a non-ascii character in the name */ - - ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR(UINT32, InternalName)); - AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName); - } - else - { - /* Convert path to external format */ - - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, - InternalName, NULL, &Name); - - /* Print target name */ - - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf ("[%s]", Name); - } - else - { - AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); - } - - if (Name) - { - ACPI_FREE (Name); - } - } - - AcpiOsPrintf (" Namespace lookup failure, %s\n", - AcpiFormatException (LookupStatus)); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsReportMethodError - * - * PARAMETERS: ModuleName - Caller's module name (for error output) - * LineNumber - Caller's line number (for error output) - * Message - Error message to use on failure - * PrefixNode - Prefix relative to the path - * Path - Path to the node (optional) - * MethodStatus - Execution status - * - * RETURN: None - * - * DESCRIPTION: Print warning message with full pathname - * - ******************************************************************************/ - -void -AcpiNsReportMethodError ( - const char *ModuleName, - UINT32 LineNumber, - const char *Message, - ACPI_NAMESPACE_NODE *PrefixNode, - const char *Path, - ACPI_STATUS MethodStatus) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = PrefixNode; - - - AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); - - if (Path) - { - Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, - &Node); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("[Could not get node by pathname]"); - } - } - - AcpiNsPrintNodePathname (Node, Message); - AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus)); -} - - /******************************************************************************* * * FUNCTION: AcpiNsPrintNodePathname @@ -389,7 +277,7 @@ AcpiNsLocal ( { /* Type code out of range */ - ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type)); return_UINT32 (ACPI_NS_NORMAL); } @@ -857,25 +745,26 @@ AcpiNsExternalizeName ( /******************************************************************************* * - * FUNCTION: AcpiNsMapHandleToNode + * FUNCTION: AcpiNsValidateHandle * - * PARAMETERS: Handle - Handle to be converted to an Node + * PARAMETERS: Handle - Handle to be validated and typecast to a + * namespace node. * - * RETURN: A Name table entry pointer + * RETURN: A pointer to a namespace node * - * DESCRIPTION: Convert a namespace handle to a real Node + * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special + * cases for the root node. * - * Note: Real integer handles would allow for more verification + * NOTE: Real integer handles would allow for more verification * and keep all pointers within this subsystem - however this introduces - * more (and perhaps unnecessary) overhead. - * - * The current implemenation is basically a placeholder until such time comes - * that it is needed. + * more overhead and has not been necessary to this point. Drivers + * holding handles are typically notified before a node becomes invalid + * due to a table unload. * ******************************************************************************/ ACPI_NAMESPACE_NODE * -AcpiNsMapHandleToNode ( +AcpiNsValidateHandle ( ACPI_HANDLE Handle) { @@ -900,48 +789,6 @@ AcpiNsMapHandleToNode ( } -/******************************************************************************* - * - * FUNCTION: AcpiNsConvertEntryToHandle - * - * PARAMETERS: Node - Node to be converted to a Handle - * - * RETURN: A user handle - * - * DESCRIPTION: Convert a real Node to a namespace handle - * - ******************************************************************************/ - -ACPI_HANDLE -AcpiNsConvertEntryToHandle ( - ACPI_NAMESPACE_NODE *Node) -{ - - - /* - * Simple implementation for now; - */ - return ((ACPI_HANDLE) Node); - - -/* Example future implementation --------------------- - - if (!Node) - { - return (NULL); - } - - if (Node == AcpiGbl_RootNode) - { - return (ACPI_ROOT_OBJECT); - } - - - return ((ACPI_HANDLE) Node); -------------------------------------------------------*/ -} - - /******************************************************************************* * * FUNCTION: AcpiNsTerminate @@ -1006,7 +853,7 @@ AcpiNsOpensScope ( { /* type code out of range */ - ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type)); return_UINT32 (ACPI_NS_NORMAL); } @@ -1048,7 +895,7 @@ AcpiNsGetNode ( char *InternalPath; - ACPI_FUNCTION_TRACE_PTR (NsGetNode, __DECONST(char *, Pathname)); + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); if (!Pathname) @@ -1098,128 +945,3 @@ Cleanup: ACPI_FREE (InternalPath); return_ACPI_STATUS (Status); } - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetParentNode - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Parent entry of the given entry - * - * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsGetParentNode ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_FUNCTION_ENTRY (); - - - if (!Node) - { - return (NULL); - } - - /* - * Walk to the end of this peer list. The last entry is marked with a flag - * and the peer pointer is really a pointer back to the parent. This saves - * putting a parent back pointer in each and every named object! - */ - while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) - { - Node = Node->Peer; - } - - return (Node->Peer); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetNextValidNode - * - * PARAMETERS: Node - Current table entry - * - * RETURN: Next valid Node in the linked node list. NULL if no more valid - * nodes. - * - * DESCRIPTION: Find the next valid node within a name table. - * Useful for implementing NULL-end-of-list loops. - * - ******************************************************************************/ - -ACPI_NAMESPACE_NODE * -AcpiNsGetNextValidNode ( - ACPI_NAMESPACE_NODE *Node) -{ - - /* If we are at the end of this peer list, return NULL */ - - if (Node->Flags & ANOBJ_END_OF_PEER_LIST) - { - return NULL; - } - - /* Otherwise just return the next peer */ - - return (Node->Peer); -} - - -#ifdef ACPI_OBSOLETE_FUNCTIONS -/******************************************************************************* - * - * FUNCTION: AcpiNsFindParentName - * - * PARAMETERS: *ChildNode - Named Obj whose name is to be found - * - * RETURN: The ACPI name - * - * DESCRIPTION: Search for the given obj in its parent scope and return the - * name segment, or "????" if the parent name can't be found - * (which "should not happen"). - * - ******************************************************************************/ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_TRACE (NsFindParentName); - - - if (ChildNode) - { - /* Valid entry. Get the parent Node */ - - ParentNode = AcpiNsGetParentNode (ChildNode); - if (ParentNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Parent of %p [%4.4s] is %p [%4.4s]\n", - ChildNode, AcpiUtGetNodeName (ChildNode), - ParentNode, AcpiUtGetNodeName (ParentNode))); - - if (ParentNode->Name.Integer) - { - return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Unable to find parent of %p (%4.4s)\n", - ChildNode, AcpiUtGetNodeName (ChildNode))); - } - - return_VALUE (ACPI_UNKNOWN_NAME); -} -#endif - - diff --git a/sys/contrib/dev/acpica-unix/namespace/nswalk.c b/sys/contrib/dev/acpica-unix/namespace/nswalk.c index 881573e905..c7d95e89cf 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nswalk.c +++ b/sys/contrib/dev/acpica-unix/namespace/nswalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -158,16 +158,6 @@ AcpiNsGetNextNode ( return (ParentNode->Child); } - /* - * Get the next node. - * - * If we are at the end of this peer list, return NULL - */ - if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - return NULL; - } - /* Otherwise just return the next peer */ return (ChildNode->Peer); @@ -227,9 +217,9 @@ AcpiNsGetNextNodeTyped ( return (NextNode); } - /* Otherwise, move on to the next node */ + /* Otherwise, move on to the next peer node */ - NextNode = AcpiNsGetNextValidNode (NextNode); + NextNode = NextNode->Peer; } /* Not found */ @@ -247,24 +237,27 @@ AcpiNsGetNextNodeTyped ( * MaxDepth - Depth to which search is to reach * Flags - Whether to unlock the NS before invoking * the callback routine - * UserFunction - Called when an object of "Type" is found - * Context - Passed to user function - * ReturnValue - from the UserFunction if terminated early. - * Otherwise, returns NULL. + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - from the UserFunction if terminated + * early. Otherwise, returns NULL. * RETURNS: Status * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, * starting (and ending) at the node specified by StartHandle. - * The UserFunction is called whenever a node that matches - * the type parameter is found. If the user function returns + * The callback function is called whenever a node that matches + * the type parameter is found. If the callback function returns * a non-zero value, the search is terminated immediately and * this value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to - * provide multiple services; the User Function can be tailored - * to each task, whether it is a print function, a compare - * function, etc. + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. * ******************************************************************************/ @@ -274,7 +267,8 @@ AcpiNsWalkNamespace ( ACPI_HANDLE StartNode, UINT32 MaxDepth, UINT32 Flags, - ACPI_WALK_CALLBACK UserFunction, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, void *Context, void **ReturnValue) { @@ -284,6 +278,7 @@ AcpiNsWalkNamespace ( ACPI_NAMESPACE_NODE *ParentNode; ACPI_OBJECT_TYPE ChildType; UINT32 Level; + BOOLEAN NodePreviouslyVisited = FALSE; ACPI_FUNCTION_TRACE (NsWalkNamespace); @@ -299,7 +294,7 @@ AcpiNsWalkNamespace ( /* Null child means "get first node" */ ParentNode = StartNode; - ChildNode = NULL; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); ChildType = ACPI_TYPE_ANY; Level = 1; @@ -308,103 +303,139 @@ AcpiNsWalkNamespace ( * 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) + while (Level > 0 && ChildNode) { - /* Get the next node in this scope. Null if not found */ - Status = AE_OK; - ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); - if (ChildNode) + + /* Found next child, get the type if we are not searching for ANY */ + + if (Type != ACPI_TYPE_ANY) { - /* Found next child, get the type if we are not searching for ANY */ + ChildType = ChildNode->Type; + } - if (Type != ACPI_TYPE_ANY) + /* + * Ignore all temporary namespace nodes (created during control + * method execution) unless told otherwise. These temporary nodes + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. + */ + if ((ChildNode->Flags & ANOBJ_TEMPORARY) && + !(Flags & ACPI_NS_WALK_TEMP_NODES)) + { + Status = AE_CTRL_DEPTH; + } + + /* Type must match requested type */ + + else if (ChildType == Type) + { + /* + * Found a matching node, invoke the user callback function. + * Unlock the namespace if flag is set. + */ + if (Flags & ACPI_NS_WALK_UNLOCK) { - ChildType = ChildNode->Type; + MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } } /* - * Ignore all temporary namespace nodes (created during control - * method execution) unless told otherwise. These temporary nodes - * can cause a race condition because they can be deleted during - * the execution of the user function (if the namespace is - * unlocked before invocation of the user function.) Only the - * debugger namespace dump will examine the temporary nodes. + * Invoke the user function, either pre-order or post-order + * or both. */ - if ((ChildNode->Flags & ANOBJ_TEMPORARY) && - !(Flags & ACPI_NS_WALK_TEMP_NODES)) + if (!NodePreviouslyVisited) { - Status = AE_CTRL_DEPTH; + if (PreOrderVisit) + { + Status = PreOrderVisit (ChildNode, Level, + Context, ReturnValue); + } } - - /* Type must match requested type */ - - else if (ChildType == Type) + else { - /* - * Found a matching node, invoke the user callback function. - * Unlock the namespace if flag is set. - */ - if (Flags & ACPI_NS_WALK_UNLOCK) + if (PostOrderVisit) { - MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (MutexStatus)) - { - return_ACPI_STATUS (MutexStatus); - } + Status = PostOrderVisit (ChildNode, Level, + Context, ReturnValue); } + } - Status = UserFunction (ChildNode, Level, Context, ReturnValue); - - if (Flags & ACPI_NS_WALK_UNLOCK) + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) { - MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (MutexStatus)) - { - return_ACPI_STATUS (MutexStatus); - } + return_ACPI_STATUS (MutexStatus); } + } - switch (Status) - { - case AE_OK: - case AE_CTRL_DEPTH: + switch (Status) + { + case AE_OK: + case AE_CTRL_DEPTH: - /* Just keep going */ - break; + /* Just keep going */ + break; - case AE_CTRL_TERMINATE: + case AE_CTRL_TERMINATE: - /* Exit now, with OK status */ + /* Exit now, with OK status */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (AE_OK); - default: + default: - /* All others are valid exceptions */ + /* All others are valid exceptions */ - return_ACPI_STATUS (Status); - } + return_ACPI_STATUS (Status); } + } - /* - * Depth first search: Attempt to go down another level in the - * namespace if we are allowed to. Don't go any further if we have - * reached the caller specified maximum depth or if the user - * function has specified that the maximum depth has been reached. - */ - if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) + /* + * Depth first search: Attempt to go down another level in the + * namespace if we are allowed to. Don't go any further if we have + * reached the caller specified maximum depth or if the user + * function has specified that the maximum depth has been reached. + */ + if (!NodePreviouslyVisited && + (Level < MaxDepth) && + (Status != AE_CTRL_DEPTH)) + { + if (ChildNode->Child) { - if (ChildNode->Child) - { - /* There is at least one child of this node, visit it */ + /* There is at least one child of this node, visit it */ - Level++; - ParentNode = ChildNode; - ChildNode = NULL; - } + Level++; + ParentNode = ChildNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + continue; } } + + /* No more children, re-visit this node */ + + if (!NodePreviouslyVisited) + { + NodePreviouslyVisited = TRUE; + continue; + } + + /* No more children, visit peers */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + NodePreviouslyVisited = FALSE; + } + + /* No peers, re-visit parent */ + else { /* @@ -413,7 +444,9 @@ AcpiNsWalkNamespace ( */ Level--; ChildNode = ParentNode; - ParentNode = AcpiNsGetParentNode (ParentNode); + ParentNode = ParentNode->Parent; + + NodePreviouslyVisited = TRUE; } } diff --git a/sys/contrib/dev/acpica-unix/namespace/nsxfeval.c b/sys/contrib/dev/acpica-unix/namespace/nsxfeval.c index c0d877839c..c3b96e30b8 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsxfeval.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -281,7 +281,7 @@ AcpiEvaluateObject ( /* Convert and validate the device handle */ - Info->PrefixNode = AcpiNsMapHandleToNode (Handle); + Info->PrefixNode = AcpiNsValidateHandle (Handle); if (!Info->PrefixNode) { Status = AE_BAD_PARAMETER; @@ -544,8 +544,11 @@ AcpiNsResolveReferences ( * 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 + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above * ReturnValue - Location where return value of * UserFunction is put if terminated early * @@ -554,16 +557,16 @@ AcpiNsResolveReferences ( * * 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 + * The callback function is called whenever an object that matches + * the type parameter is found. If the callback function returns * a non-zero value, the search is terminated immediately and this * value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to - * provide multiple services; the User Function can be tailored - * to each task, whether it is a print function, a compare - * function, etc. + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. * ******************************************************************************/ @@ -572,7 +575,8 @@ AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, - ACPI_WALK_CALLBACK UserFunction, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, void *Context, void **ReturnValue) { @@ -586,7 +590,7 @@ AcpiWalkNamespace ( if ((Type > ACPI_TYPE_LOCAL_MAX) || (!MaxDepth) || - (!UserFunction)) + (!PreOrderVisit && !PostOrderVisit)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -621,7 +625,8 @@ AcpiWalkNamespace ( } Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, - ACPI_NS_WALK_UNLOCK, UserFunction, Context, ReturnValue); + ACPI_NS_WALK_UNLOCK, PreOrderVisit, + PostOrderVisit, Context, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -658,10 +663,11 @@ AcpiNsGetDeviceCallback ( ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; UINT32 Flags; - ACPI_DEVICE_ID Hid; - ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; UINT32 i; BOOLEAN Found; + int NoMatch; Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -670,7 +676,7 @@ AcpiNsGetDeviceCallback ( return (Status); } - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { @@ -682,27 +688,20 @@ AcpiNsGetDeviceCallback ( return (AE_BAD_PARAMETER); } - /* Run _STA to determine if device is present */ - - Status = AcpiUtExecute_STA (Node, &Flags); - if (ACPI_FAILURE (Status)) - { - return (AE_CTRL_DEPTH); - } - - if (!(Flags & ACPI_STA_DEVICE_PRESENT) && - !(Flags & ACPI_STA_DEVICE_FUNCTIONING)) - { - /* - * Don't examine the children of the device only when the - * device is neither present nor functional. See ACPI spec, - * description of _STA for more information. - */ - return (AE_CTRL_DEPTH); - } - - /* Filter based on device HID & CID */ - + /* + * First, filter based on the device HID and CID. + * + * 01/2010: For this case where a specific HID is requested, we don't + * want to run _STA until we have an actual HID match. Thus, we will + * not unnecessarily execute _STA on devices for which the caller + * doesn't care about. Previously, _STA was executed unconditionally + * on all devices found here. + * + * A side-effect of this change is that now we will continue to search + * for a matching HID even under device trees where the parent device + * would have returned a _STA that indicates it is not present or + * not functioning (thus aborting the search on that branch). + */ if (Info->Hid != NULL) { Status = AcpiUtExecute_HID (Node, &Hid); @@ -715,7 +714,10 @@ AcpiNsGetDeviceCallback ( return (AE_CTRL_DEPTH); } - if (ACPI_STRNCMP (Hid.Value, Info->Hid, sizeof (Hid.Value)) != 0) + NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + ACPI_FREE (Hid); + + if (NoMatch) { /* * HID does not match, attempt match within the @@ -736,8 +738,7 @@ AcpiNsGetDeviceCallback ( Found = FALSE; for (i = 0; i < Cid->Count; i++) { - if (ACPI_STRNCMP (Cid->Id[i].Value, Info->Hid, - sizeof (ACPI_COMPATIBLE_ID)) == 0) + if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) { /* Found a matching CID */ @@ -754,6 +755,25 @@ AcpiNsGetDeviceCallback ( } } + /* Run _STA to determine if device is present */ + + Status = AcpiUtExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + if (!(Flags & ACPI_STA_DEVICE_PRESENT) && + !(Flags & ACPI_STA_DEVICE_FUNCTIONING)) + { + /* + * Don't examine the children of the device only when the + * device is neither present nor functional. See ACPI spec, + * description of _STA for more information. + */ + return (AE_CTRL_DEPTH); + } + /* We have a valid device, invoke the user function */ Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, @@ -830,7 +850,7 @@ AcpiGetDevices ( Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiNsGetDeviceCallback, &Info, ReturnValue); + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); @@ -880,7 +900,7 @@ AcpiAttachData ( /* Convert and validate the handle */ - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; @@ -935,7 +955,7 @@ AcpiDetachData ( /* Convert and validate the handle */ - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; @@ -993,7 +1013,7 @@ AcpiGetData ( /* Convert and validate the handle */ - Node = AcpiNsMapHandleToNode (ObjHandle); + Node = AcpiNsValidateHandle (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; diff --git a/sys/contrib/dev/acpica-unix/namespace/nsxfname.c b/sys/contrib/dev/acpica-unix/namespace/nsxfname.c index 49ccb58092..b09138226e 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsxfname.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsxfname.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,14 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsxfname") +/* Local prototypes */ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea); + /****************************************************************************** * @@ -170,7 +178,7 @@ AcpiGetHandle ( if (Parent) { - PrefixNode = AcpiNsMapHandleToNode (Parent); + PrefixNode = AcpiNsValidateHandle (Parent); if (!PrefixNode) { return (AE_BAD_PARAMETER); @@ -192,7 +200,7 @@ AcpiGetHandle ( if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) { - *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); return (AE_OK); } } @@ -208,7 +216,7 @@ AcpiGetHandle ( Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_SUCCESS (Status)) { - *RetHandle = AcpiNsConvertEntryToHandle (Node); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); } return (Status); @@ -274,7 +282,7 @@ AcpiGetName ( return (Status); } - Node = AcpiNsMapHandleToNode (Handle); + Node = AcpiNsValidateHandle (Handle); if (!Node) { Status = AE_BAD_PARAMETER; @@ -306,12 +314,44 @@ UnlockAndExit: ACPI_EXPORT_SYMBOL (AcpiGetName) +/****************************************************************************** + * + * FUNCTION: AcpiNsCopyDeviceId + * + * PARAMETERS: Dest - Pointer to the destination DEVICE_ID + * Source - Pointer to the source DEVICE_ID + * StringArea - Pointer to where to copy the dest string + * + * RETURN: Pointer to the next string area + * + * DESCRIPTION: Copy a single DEVICE_ID, including the string data. + * + ******************************************************************************/ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea) +{ + /* Create the destination DEVICE_ID */ + + Dest->String = StringArea; + Dest->Length = Source->Length; + + /* Copy actual string and return a pointer to the next string area */ + + ACPI_MEMCPY (StringArea, Source->String, Source->Length); + return (StringArea + Source->Length); +} + + /****************************************************************************** * * FUNCTION: AcpiGetObjectInfo * - * PARAMETERS: Handle - Object Handle - * Buffer - Where the info is returned + * PARAMETERS: Handle - Object Handle + * ReturnBuffer - Where the info is returned * * RETURN: Status * @@ -319,38 +359,39 @@ ACPI_EXPORT_SYMBOL (AcpiGetName) * namespace node and possibly by running several standard * control methods (Such as in the case of a device.) * + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _ADR, _SxW, and _SxD methods. + * + * Note: Allocates the return buffer, must be freed by the caller. + * ******************************************************************************/ ACPI_STATUS AcpiGetObjectInfo ( ACPI_HANDLE Handle, - ACPI_BUFFER *Buffer) + ACPI_DEVICE_INFO **ReturnBuffer) { - ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_DEVICE_INFO *Info; - ACPI_DEVICE_INFO *ReturnInfo; - ACPI_COMPATIBLE_ID_LIST *CidList = NULL; - ACPI_SIZE Size; + ACPI_DEVICE_ID_LIST *CidList = NULL; + ACPI_DEVICE_ID *Hid = NULL; + ACPI_DEVICE_ID *Uid = NULL; + char *NextIdString; + ACPI_OBJECT_TYPE Type; + ACPI_NAME Name; + UINT8 ParamCount= 0; + UINT8 Valid = 0; + UINT32 InfoSize; + UINT32 i; + ACPI_STATUS Status; + ACPI_FUNCTION_TRACE (GetObjectInfo); /* Parameter validation */ - if (!Handle || !Buffer) + if (!Handle || !ReturnBuffer) { - return (AE_BAD_PARAMETER); - } - - Status = AcpiUtValidateBuffer (Buffer); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_INFO)); - if (!Info) - { - return (AE_NO_MEMORY); + return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -359,60 +400,58 @@ AcpiGetObjectInfo ( goto Cleanup; } - Node = AcpiNsMapHandleToNode (Handle); + Node = AcpiNsValidateHandle (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - Status = AE_BAD_PARAMETER; - goto Cleanup; + return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Init return structure */ + /* Get the namespace node data while the namespace is locked */ - Size = sizeof (ACPI_DEVICE_INFO); - - Info->Type = Node->Type; - Info->Name = Node->Name.Integer; - Info->Valid = 0; + InfoSize = sizeof (ACPI_DEVICE_INFO); + Type = Node->Type; + Name = Node->Name.Integer; if (Node->Type == ACPI_TYPE_METHOD) { - Info->ParamCount = Node->Object->Method.ParamCount; + ParamCount = Node->Object->Method.ParamCount; } Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - goto Cleanup; + return_ACPI_STATUS (Status); } - /* If not a device, we are all done */ - - if (Info->Type == ACPI_TYPE_DEVICE) + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) { /* - * Get extra info for ACPI Devices objects only: - * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. + * Get extra info for ACPI Device/Processor objects only: + * Run the Device _HID, _UID, and _CID methods. * * Note: none of these methods are required, so they may or may - * not be present for this device. The Info->Valid bitfield is used - * to indicate which methods were found and ran successfully. + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. */ /* Execute the Device._HID method */ - Status = AcpiUtExecute_HID (Node, &Info->HardwareId); + Status = AcpiUtExecute_HID (Node, &Hid); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_HID; + InfoSize += Hid->Length; + Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ - Status = AcpiUtExecute_UID (Node, &Info->UniqueId); + Status = AcpiUtExecute_UID (Node, &Uid); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_UID; + InfoSize += Uid->Length; + Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ @@ -420,62 +459,156 @@ AcpiGetObjectInfo ( Status = AcpiUtExecute_CID (Node, &CidList); if (ACPI_SUCCESS (Status)) { - Size += CidList->Size; - Info->Valid |= ACPI_VALID_CID; + /* Add size of CID strings and CID pointer array */ + + InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST)); + Valid |= ACPI_VALID_CID; } + } + + /* + * Now that we have the variable-length data, we can allocate the + * return buffer + */ + Info = ACPI_ALLOCATE_ZEROED (InfoSize); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the fixed-length data */ + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the _STA, _ADR and, SxW, and _SxD methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ /* Execute the Device._STA method */ Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_STA; + Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info->Address); + &Info->Address); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_ADR; + } + + /* Execute the Device._SxW methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_ADR; + Valid |= ACPI_VALID_SXWS; } /* Execute the Device._SxD methods */ - Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); if (ACPI_SUCCESS (Status)) { - Info->Valid |= ACPI_VALID_SXDS; + Valid |= ACPI_VALID_SXDS; } } - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (Buffer, Size); - if (ACPI_FAILURE (Status)) + /* + * Create a pointer to the string area of the return buffer. + * Point to the end of the base ACPI_DEVICE_INFO structure. + */ + NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); + if (CidList) { - goto Cleanup; + /* Point past the CID DEVICE_ID array */ + + NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID)); } - /* Populate the return buffer */ + /* + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. + * + * For HID and CID, check if the ID is a PCI Root Bridge. + */ + if (Hid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, + Hid, NextIdString); + + if (AcpiUtIsPciRootBridge (Hid->String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } - ReturnInfo = Buffer->Pointer; - ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); + if (Uid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, + Uid, NextIdString); + } if (CidList) { - ACPI_MEMCPY (&ReturnInfo->CompatibilityId, CidList, CidList->Size); + Info->CompatibleIdList.Count = CidList->Count; + Info->CompatibleIdList.ListSize = CidList->ListSize; + + /* Copy each CID */ + + for (i = 0; i < CidList->Count; i++) + { + NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], + &CidList->Ids[i], NextIdString); + + if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } } + /* Copy the fixed-length data */ + + Info->InfoSize = InfoSize; + Info->Type = Type; + Info->Name = Name; + Info->ParamCount = ParamCount; + Info->Valid = Valid; + + *ReturnBuffer = Info; + Status = AE_OK; + Cleanup: - ACPI_FREE (Info); + if (Hid) + { + ACPI_FREE (Hid); + } + if (Uid) + { + ACPI_FREE (Uid); + } if (CidList) { ACPI_FREE (CidList); } - return (Status); + return_ACPI_STATUS (Status); } ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) @@ -606,11 +739,10 @@ AcpiInstallMethod ( MethodObj->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); - MethodObj->Method.MethodFlags = (UINT8) - (MethodFlags & ~AML_METHOD_ARG_COUNT); - if (MethodFlags & AML_METHOD_SERIALIZED) { + MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED; + MethodObj->Method.SyncLevel = (UINT8) ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); } @@ -619,8 +751,7 @@ AcpiInstallMethod ( * Now that it is complete, we can attach the new method object to * the method Node (detaches/deletes any existing object) */ - Status = AcpiNsAttachObject (Node, MethodObj, - ACPI_TYPE_METHOD); + Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD); /* * Flag indicates AML buffer is dynamic, must be deleted later. diff --git a/sys/contrib/dev/acpica-unix/namespace/nsxfobj.c b/sys/contrib/dev/acpica-unix/namespace/nsxfobj.c index 023cb6990b..5dca29cd81 100644 --- a/sys/contrib/dev/acpica-unix/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica-unix/namespace/nsxfobj.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -172,7 +172,7 @@ AcpiGetType ( /* Convert and validate the handle */ - Node = AcpiNsMapHandleToNode (Handle); + Node = AcpiNsValidateHandle (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -233,7 +233,7 @@ AcpiGetParent ( /* Convert and validate the handle */ - Node = AcpiNsMapHandleToNode (Handle); + Node = AcpiNsValidateHandle (Handle); if (!Node) { Status = AE_BAD_PARAMETER; @@ -242,8 +242,8 @@ AcpiGetParent ( /* Get the parent entry */ - ParentNode = AcpiNsGetParentNode (Node); - *RetHandle = AcpiNsConvertEntryToHandle (ParentNode); + ParentNode = Node->Parent; + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode); /* Return exception if parent is null */ @@ -312,7 +312,7 @@ AcpiGetNextObject ( { /* Start search at the beginning of the specified scope */ - ParentNode = AcpiNsMapHandleToNode (Parent); + ParentNode = AcpiNsValidateHandle (Parent); if (!ParentNode) { Status = AE_BAD_PARAMETER; @@ -324,7 +324,7 @@ AcpiGetNextObject ( /* Non-null handle, ignore the parent */ /* Convert and validate the handle */ - ChildNode = AcpiNsMapHandleToNode (Child); + ChildNode = AcpiNsValidateHandle (Child); if (!ChildNode) { Status = AE_BAD_PARAMETER; @@ -343,7 +343,7 @@ AcpiGetNextObject ( if (RetHandle) { - *RetHandle = AcpiNsConvertEntryToHandle (Node); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); } diff --git a/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixdir.c b/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixdir.c index d9c55a1ef8..0ca569efda 100644 --- a/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixdir.c +++ b/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixdir.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,9 @@ #include "acpisrc.h" +/* + * Allocated structure returned from OsOpenDirectory + */ typedef struct ExternalFindInfo { char *DirPathname; @@ -193,7 +196,7 @@ AcpiOsOpenDirectory ( * * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory * - * RETURN: Next filename matched. NULL if no more matches. + * RETURN: Next filename matched. NULL if no more matches. * * DESCRIPTION: Get the next file in the directory that matches the wildcard * specification. @@ -217,7 +220,9 @@ AcpiOsGetNextFilename ( if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0)) { if (dir_entry->d_name[0] == '.') + { continue; + } str_len = strlen (dir_entry->d_name) + strlen (ExternalInfo->DirPathname) + 2; @@ -226,7 +231,7 @@ AcpiOsGetNextFilename ( if (!temp_str) { printf ("Could not allocate buffer for temporary string\n"); - return NULL; + return (NULL); } strcpy (temp_str, ExternalInfo->DirPathname); @@ -238,7 +243,7 @@ AcpiOsGetNextFilename ( if (err == -1) { printf ("stat() error - should not happen\n"); - return NULL; + return (NULL); } if ((S_ISDIR (temp_stat.st_mode) @@ -255,7 +260,7 @@ AcpiOsGetNextFilename ( } } - return NULL; + return (NULL); } @@ -284,10 +289,22 @@ AcpiOsCloseDirectory ( free (DirHandle); } + /* Other functions acpisrc uses but that aren't standard on Unix */ -/* lowercase a string */ -char* +/******************************************************************************* + * + * FUNCTION: strlwr + * + * PARAMETERS: str - String to be lowercased. + * + * RETURN: str. + * + * DESCRIPTION: Lowercase a string in-place. + * + ******************************************************************************/ + +char * strlwr ( char *str) { @@ -295,11 +312,11 @@ strlwr ( int i; - length = strlen(str); + length = strlen (str); for (i = 0; i < length; i++) { - str[i] = tolower(str[i]); + str[i] = tolower ((int) str[i]); } return (str); diff --git a/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixxf.c index b430e83f16..a9e3763a60 100644 --- a/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixxf.c +++ b/sys/contrib/dev/acpica-unix/os_specific/service_layers/osunixxf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -115,10 +115,11 @@ /* - * These interfaces are required in order to compile the ASL compiler under - * Linux or other Unix-like system. + * These interfaces are required in order to compile the ASL compiler and the + * various ACPICA tools under Linux or other Unix-like system. + * + * Note: Use #define __APPLE__ for OS X generation. */ - #include #include #include @@ -126,6 +127,7 @@ #include #include #include +#include #include "acpi.h" #include "accommon.h" @@ -154,6 +156,12 @@ AeTableOverride ( typedef void* (*PTHREAD_CALLBACK) (void *); +/* Apple-specific */ + +#ifdef __APPLE__ +#define sem_destroy sem_close +#endif + /****************************************************************************** * @@ -163,12 +171,13 @@ typedef void* (*PTHREAD_CALLBACK) (void *); * * RETURN: Status * - * DESCRIPTION: Init and terminate. Nothing to do. + * DESCRIPTION: Init and terminate. Nothing to do. * *****************************************************************************/ ACPI_STATUS -AcpiOsInitialize (void) +AcpiOsInitialize ( + void) { AcpiGbl_OutputFile = stdout; @@ -177,7 +186,8 @@ AcpiOsInitialize (void) ACPI_STATUS -AcpiOsTerminate (void) +AcpiOsTerminate ( + void) { return (AE_OK); @@ -192,7 +202,7 @@ AcpiOsTerminate (void) * * RETURN: RSDP physical address * - * DESCRIPTION: Gets the root pointer (RSDP) + * DESCRIPTION: Gets the ACPI root pointer (RSDP) * *****************************************************************************/ @@ -209,10 +219,10 @@ AcpiOsGetRootPointer ( * * FUNCTION: AcpiOsPredefinedOverride * - * PARAMETERS: InitVal - Initial value of the predefined object - * NewVal - The new value for the object + * PARAMETERS: InitVal - Initial value of the predefined object + * NewVal - The new value for the object * - * RETURN: Status, pointer to value. Null pointer returned if not + * RETURN: Status, pointer to value. Null pointer returned if not * overriding. * * DESCRIPTION: Allow the OS to override predefined names @@ -239,10 +249,11 @@ AcpiOsPredefinedOverride ( * * FUNCTION: AcpiOsTableOverride * - * PARAMETERS: ExistingTable - Header of current table (probably firmware) - * NewTable - Where an entire new table is returned. + * PARAMETERS: ExistingTable - Header of current table (probably + * firmware) + * NewTable - Where an entire new table is returned. * - * RETURN: Status, pointer to new table. Null pointer returned if no + * RETURN: Status, pointer to new table. Null pointer returned if no * table is available to override * * DESCRIPTION: Return a different version of a table if one is available @@ -298,7 +309,7 @@ AcpiOsRedirectOutput ( * * FUNCTION: AcpiOsPrintf * - * PARAMETERS: fmt, ... Standard printf format + * PARAMETERS: fmt, ... - Standard printf format * * RETURN: None * @@ -324,8 +335,8 @@ AcpiOsPrintf ( * * FUNCTION: AcpiOsVprintf * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: fmt - Standard printf format + * args - Argument list * * RETURN: None * @@ -372,8 +383,8 @@ AcpiOsVprintf ( * * FUNCTION: AcpiOsGetLine * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: fmt - Standard printf format + * args - Argument list * * RETURN: Actual bytes read * @@ -409,14 +420,15 @@ AcpiOsGetLine ( return (i); } + /****************************************************************************** * * FUNCTION: AcpiOsMapMemory * - * PARAMETERS: where Physical address of memory to be mapped - * length How much memory to map + * PARAMETERS: where - Physical address of memory to be mapped + * length - How much memory to map * - * RETURN: Pointer to mapped memory. Null on error. + * RETURN: Pointer to mapped memory. Null on error. * * DESCRIPTION: Map physical memory into caller's address space * @@ -436,12 +448,12 @@ AcpiOsMapMemory ( * * FUNCTION: AcpiOsUnmapMemory * - * PARAMETERS: where Logical address of memory to be unmapped - * length How much memory to unmap + * PARAMETERS: where - Logical address of memory to be unmapped + * length - How much memory to unmap * * RETURN: None. * - * DESCRIPTION: Delete a previously created mapping. Where and Length must + * DESCRIPTION: Delete a previously created mapping. Where and Length must * correspond to a previous mapping exactly. * *****************************************************************************/ @@ -460,11 +472,11 @@ AcpiOsUnmapMemory ( * * FUNCTION: AcpiOsAllocate * - * PARAMETERS: Size Amount to allocate, in bytes + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/ @@ -484,7 +496,7 @@ AcpiOsAllocate ( * * FUNCTION: AcpiOsFree * - * PARAMETERS: mem Pointer to previously allocated memory + * PARAMETERS: mem - Pointer to previously allocated memory * * RETURN: None. * @@ -501,6 +513,52 @@ AcpiOsFree ( } +#ifdef ACPI_SINGLE_THREADED +/****************************************************************************** + * + * FUNCTION: Semaphore stub functions + * + * DESCRIPTION: Stub functions used for single-thread applications that do + * not require semaphore synchronization. Full implementations + * of these functions appear after the stubs. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + *OutHandle = (ACPI_HANDLE) 1; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + return (AE_OK); +} + +#else /****************************************************************************** * * FUNCTION: AcpiOsCreateSemaphore @@ -528,8 +586,20 @@ AcpiOsCreateSemaphore ( return (AE_BAD_PARAMETER); } - Sem = AcpiOsAllocate (sizeof (sem_t)); +#ifdef __APPLE__ + { + char *SemaphoreName = tmpnam (NULL); + Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); + if (!Sem) + { + return (AE_NO_MEMORY); + } + sem_unlink (SemaphoreName); /* This just deletes the name */ + } + +#else + Sem = AcpiOsAllocate (sizeof (sem_t)); if (!Sem) { return (AE_NO_MEMORY); @@ -540,6 +610,7 @@ AcpiOsCreateSemaphore ( AcpiOsFree (Sem); return (AE_BAD_PARAMETER); } +#endif *OutHandle = (ACPI_HANDLE) Sem; return (AE_OK); @@ -708,6 +779,8 @@ AcpiOsSignalSemaphore ( return (AE_OK); } +#endif /* ACPI_SINGLE_THREADED */ + /****************************************************************************** * @@ -756,13 +829,13 @@ AcpiOsReleaseLock ( * * FUNCTION: AcpiOsInstallInterruptHandler * - * PARAMETERS: InterruptNumber Level handler should respond to. - * Isr Address of the ACPI interrupt handler - * ExceptPtr Where status is returned + * PARAMETERS: InterruptNumber - Level handler should respond to. + * Isr - Address of the ACPI interrupt handler + * ExceptPtr - Where status is returned * * RETURN: Handle to the newly installed handler. * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI + * DESCRIPTION: Install an interrupt handler. Used to install the ACPI * OS-independent handler. * *****************************************************************************/ @@ -782,7 +855,7 @@ AcpiOsInstallInterruptHandler ( * * FUNCTION: AcpiOsRemoveInterruptHandler * - * PARAMETERS: Handle Returned when handler was installed + * PARAMETERS: Handle - Returned when handler was installed * * RETURN: Status * @@ -804,9 +877,9 @@ AcpiOsRemoveInterruptHandler ( * * FUNCTION: AcpiOsExecute * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function * * RETURN: Status. * @@ -837,7 +910,7 @@ AcpiOsExecute ( * * FUNCTION: AcpiOsStall * - * PARAMETERS: microseconds To sleep + * PARAMETERS: microseconds - Time to sleep * * RETURN: Blocks until sleep is completed. * @@ -861,7 +934,7 @@ AcpiOsStall ( * * FUNCTION: AcpiOsSleep * - * PARAMETERS: milliseconds To sleep + * PARAMETERS: milliseconds - Time to sleep * * RETURN: Blocks until sleep is completed. * @@ -871,7 +944,7 @@ AcpiOsStall ( void AcpiOsSleep ( - ACPI_INTEGER milliseconds) + UINT64 milliseconds) { sleep (milliseconds / 1000); /* Sleep for whole seconds */ @@ -882,6 +955,7 @@ AcpiOsSleep ( usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */ } + /****************************************************************************** * * FUNCTION: AcpiOsGetTimer @@ -895,7 +969,8 @@ AcpiOsSleep ( *****************************************************************************/ UINT64 -AcpiOsGetTimer (void) +AcpiOsGetTimer ( + void) { struct timeval time; @@ -908,36 +983,14 @@ AcpiOsGetTimer (void) } -/****************************************************************************** - * - * FUNCTION: AcpiOsValidateInterface - * - * PARAMETERS: Interface - Requested interface to be validated - * - * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise - * - * DESCRIPTION: Match an interface string to the interfaces supported by the - * host. Strings originate from an AML call to the _OSI method. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsValidateInterface ( - char *Interface) -{ - - return (AE_SUPPORT); -} - - /****************************************************************************** * * FUNCTION: AcpiOsReadPciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Buffer where value is placed - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Buffer where value is placed + * Width - Number of bits * * RETURN: Status * @@ -949,7 +1002,7 @@ ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - void *Value, + UINT64 *Value, UINT32 Width) { @@ -961,10 +1014,10 @@ AcpiOsReadPciConfiguration ( * * FUNCTION: AcpiOsWritePciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Value to be written - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Value to be written + * Width - Number of bits * * RETURN: Status. * @@ -976,31 +1029,21 @@ ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - ACPI_INTEGER Value, + UINT64 Value, UINT32 Width) { return (AE_OK); } -/* TEMPORARY STUB FUNCTION */ -void -AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, - ACPI_PCI_ID **PciId) -{ - -} - /****************************************************************************** * * FUNCTION: AcpiOsReadPort * - * PARAMETERS: Address Address of I/O port/register to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from port * @@ -1041,9 +1084,9 @@ AcpiOsReadPort ( * * FUNCTION: AcpiOsWritePort * - * PARAMETERS: Address Address of I/O port/register to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1066,9 +1109,9 @@ AcpiOsWritePort ( * * FUNCTION: AcpiOsReadMemory * - * PARAMETERS: Address Physical Memory Address to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from physical memory address * @@ -1102,9 +1145,9 @@ AcpiOsReadMemory ( * * FUNCTION: AcpiOsWriteMemory * - * PARAMETERS: Address Physical Memory Address to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1177,18 +1220,16 @@ AcpiOsWritable ( * * RETURN: Id of the running thread * - * DESCRIPTION: Get the Id of the current (running) thread - * - * NOTE: The environment header should contain this line: - * #define ACPI_THREAD_ID pthread_t + * DESCRIPTION: Get the ID of the current (running) thread * *****************************************************************************/ ACPI_THREAD_ID -AcpiOsGetThreadId (void) +AcpiOsGetThreadId ( + void) { - return (pthread_self ()); + return (ACPI_CAST_PTHREAD_T (pthread_self())); } @@ -1196,8 +1237,8 @@ AcpiOsGetThreadId (void) * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function ACPI CA signal function code - * Info Pointer to function-dependent structure + * PARAMETERS: Function - ACPI CA signal function code + * Info - Pointer to function-dependent structure * * RETURN: Status * @@ -1225,5 +1266,3 @@ AcpiOsSignal ( return (AE_OK); } - - diff --git a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswindir.c b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswindir.c index 445813d7b7..42acaddbc6 100644 --- a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswindir.c +++ b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswindir.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,14 +114,13 @@ * *****************************************************************************/ +#include #include #include #include #include -#include - typedef struct ExternalFindInfo { struct _finddata_t DosInfo; @@ -171,7 +170,7 @@ AcpiOsOpenDirectory ( SearchInfo = calloc (sizeof (EXTERNAL_FIND_INFO), 1); if (!SearchInfo) { - return NULL; + return (NULL); } /* Allocate space for the full wildcard path */ @@ -180,7 +179,7 @@ AcpiOsOpenDirectory ( if (!FullWildcardSpec) { printf ("Could not allocate buffer for wildcard pathname\n"); - return NULL; + return (NULL); } /* Create the full wildcard path */ @@ -198,7 +197,7 @@ AcpiOsOpenDirectory ( free (FullWildcardSpec); free (SearchInfo); - return NULL; + return (NULL); } /* Save the info in the return structure */ @@ -217,7 +216,7 @@ AcpiOsOpenDirectory ( * * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory * - * RETURN: Next filename matched. NULL if no more matches. + * RETURN: Next filename matched. NULL if no more matches. * * DESCRIPTION: Get the next file in the directory that matches the wildcard * specification. @@ -254,7 +253,7 @@ AcpiOsGetNextFilename ( Status = _findnext (SearchInfo->FindHandle, &SearchInfo->DosInfo); if (Status != 0) { - return NULL; + return (NULL); } } @@ -288,7 +287,7 @@ AcpiOsGetNextFilename ( break; default: - return NULL; + return (NULL); } } @@ -302,7 +301,7 @@ AcpiOsGetNextFilename ( * * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory * - * RETURN: None. + * RETURN: None * * DESCRIPTION: Close the open directory and cleanup. * diff --git a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswintbl.c b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswintbl.c index 889582ff75..a058f56926 100644 --- a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswintbl.c +++ b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswintbl.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,24 +114,37 @@ *****************************************************************************/ +#include "acpi.h" + #ifdef WIN32 #pragma warning(disable:4115) /* warning C4115: (caused by rpcasync.h) */ - #include -#include #elif WIN64 #include #endif -#include "acpi.h" -#include "accommon.h" - #define _COMPONENT ACPI_OS_SERVICES ACPI_MODULE_NAME ("oswintbl") static char KeyBuffer[64]; +static char ErrorBuffer[64]; + + +/* Little front-end to win FormatMessage */ + +char * +OsFormatException ( + LONG Status) +{ + + ErrorBuffer[0] = 0; + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, Status, 0, + ErrorBuffer, 64, NULL); + + return (ErrorBuffer); +} /****************************************************************************** @@ -169,7 +182,7 @@ OsGetTable ( ACPI_STRCAT (KeyBuffer, Signature); Status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, KeyBuffer, - 0L, KEY_ALL_ACCESS, &Handle); + 0L, KEY_READ, &Handle); if (Status != ERROR_SUCCESS) { @@ -187,8 +200,9 @@ OsGetTable ( } else { - AcpiOsPrintf ("Could not find %s in registry at %s\n", - Signature, KeyBuffer); + AcpiOsPrintf ( + "Could not find %s in registry at %s: %s (Status=0x%X)\n", + Signature, KeyBuffer, OsFormatException (Status), Status); return (NULL); } } @@ -212,7 +226,8 @@ OsGetTable ( Status = RegOpenKey (Handle, KeyBuffer, &SubKey); if (Status != ERROR_SUCCESS) { - AcpiOsPrintf ("Could not open %s entry\n", Signature); + AcpiOsPrintf ("Could not open %s entry: %s\n", + Signature, OsFormatException (Status)); return (NULL); } @@ -230,7 +245,8 @@ OsGetTable ( NULL, &Type, NULL, 0); if (Status != ERROR_SUCCESS) { - AcpiOsPrintf ("Could not get %s registry entry\n", Signature); + AcpiOsPrintf ("Could not get %s registry entry: %s\n", + Signature, OsFormatException (Status)); return (NULL); } @@ -246,7 +262,8 @@ OsGetTable ( Status = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize); if (Status != ERROR_SUCCESS) { - AcpiOsPrintf ("Could not read the %s table size\n", Signature); + AcpiOsPrintf ("Could not read the %s table size: %s\n", + Signature, OsFormatException (Status)); return (NULL); } @@ -264,7 +281,8 @@ OsGetTable ( (UCHAR *) ReturnTable, &DataSize); if (Status != ERROR_SUCCESS) { - AcpiOsPrintf ("Could not read %s data\n", Signature); + AcpiOsPrintf ("Could not read %s data: %s\n", + Signature, OsFormatException (Status)); AcpiOsFree (ReturnTable); return (NULL); } diff --git a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswinxf.c b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswinxf.c index 166e5e250a..1fb7696995 100644 --- a/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswinxf.c +++ b/sys/contrib/dev/acpica-unix/os_specific/service_layers/oswinxf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,6 +113,8 @@ * *****************************************************************************/ +#include "acpi.h" +#include "accommon.h" #ifdef WIN32 #pragma warning(disable:4115) /* warning C4115: named type definition in parentheses (caused by rpcasync.h> */ @@ -130,31 +132,21 @@ #include #include -#include "acpi.h" -#include "accommon.h" - #define _COMPONENT ACPI_OS_SERVICES ACPI_MODULE_NAME ("oswinxf") -/* Semaphore information structure */ - -typedef struct acpi_os_semaphore_info -{ - UINT16 MaxUnits; - UINT16 CurrentUnits; - void *OsHandle; - -} ACPI_OS_SEMAPHORE_INFO; - -/* Need enough semaphores to run the large aslts suite */ +extern FILE *AcpiGbl_DebugFile; +extern BOOLEAN AcpiGbl_DebugTimeout; -#define ACPI_OS_MAX_SEMAPHORES 256 +FILE *AcpiGbl_OutputFile; +UINT64 TimerFrequency; +char TableName[ACPI_NAME_SIZE + 1]; -ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES]; +#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */ -/* Upcalls to AcpiExec */ +/* Upcalls to application */ ACPI_PHYSICAL_ADDRESS AeLocalGetRootPointer ( @@ -170,14 +162,28 @@ OsGetTable ( char *Signature); -extern FILE *AcpiGbl_DebugFile; -extern BOOLEAN AcpiGbl_DebugTimeout; +/* + * Real semaphores are only used for a multi-threaded application + */ +#ifndef ACPI_SINGLE_THREADED -FILE *AcpiGbl_OutputFile; -UINT64 TimerFrequency; -char TableName[ACPI_NAME_SIZE + 1]; +/* Semaphore information structure */ -#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */ +typedef struct acpi_os_semaphore_info +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; + +} ACPI_OS_SEMAPHORE_INFO; + +/* Need enough semaphores to run the large aslts suite */ + +#define ACPI_OS_MAX_SEMAPHORES 256 + +ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES]; + +#endif /* ACPI_SINGLE_THREADED */ /****************************************************************************** @@ -186,16 +192,17 @@ char TableName[ACPI_NAME_SIZE + 1]; * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Nothing to do for windows * *****************************************************************************/ ACPI_STATUS -AcpiOsTerminate (void) +AcpiOsTerminate ( + void) { - return AE_OK; + return (AE_OK); } @@ -212,16 +219,19 @@ AcpiOsTerminate (void) *****************************************************************************/ ACPI_STATUS -AcpiOsInitialize (void) +AcpiOsInitialize ( + void) { LARGE_INTEGER LocalTimerFrequency; - AcpiGbl_OutputFile = stdout; - +#ifndef ACPI_SINGLE_THREADED /* Clear the semaphore info array */ memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores)); +#endif + + AcpiGbl_OutputFile = stdout; /* Get the timer frequency for use in AcpiOsGetTimer */ @@ -233,7 +243,7 @@ AcpiOsInitialize (void) TimerFrequency = LocalTimerFrequency.QuadPart; } - return AE_OK; + return (AE_OK); } @@ -262,10 +272,10 @@ AcpiOsGetRootPointer ( * * FUNCTION: AcpiOsPredefinedOverride * - * PARAMETERS: InitVal - Initial value of the predefined object - * NewVal - The new value for the object + * PARAMETERS: InitVal - Initial value of the predefined object + * NewVal - The new value for the object * - * RETURN: Status, pointer to value. Null pointer returned if not + * RETURN: Status, pointer to value. Null pointer returned if not * overriding. * * DESCRIPTION: Allow the OS to override predefined names @@ -292,10 +302,10 @@ AcpiOsPredefinedOverride ( * * FUNCTION: AcpiOsTableOverride * - * PARAMETERS: ExistingTable - Header of current table (probably firmware) - * NewTable - Where an entire new table is returned. + * PARAMETERS: ExistingTable - Header of current table (probably firmware) + * NewTable - Where an entire new table is returned. * - * RETURN: Status, pointer to new table. Null pointer returned if no + * RETURN: Status, pointer to new table. Null pointer returned if no * table is available to override * * DESCRIPTION: Return a different version of a table if one is available @@ -336,7 +346,7 @@ AcpiOsTableOverride ( *NewTable = OsGetTable (TableName); if (*NewTable) { - AcpiOsPrintf ("Table %s obtained from registry, %d bytes\n", + AcpiOsPrintf ("Table [%s] obtained from registry, %u bytes\n", TableName, (*NewTable)->Length); } else @@ -460,7 +470,7 @@ AcpiOsRedirectOutput ( * * FUNCTION: AcpiOsPrintf * - * PARAMETERS: fmt, ... Standard printf format + * PARAMETERS: Fmt, ... - Standard printf format * * RETURN: None * @@ -489,8 +499,8 @@ AcpiOsPrintf ( * * FUNCTION: AcpiOsVprintf * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: Fmt - Standard printf format + * Args - Argument list * * RETURN: None * @@ -539,8 +549,7 @@ AcpiOsVprintf ( * * FUNCTION: AcpiOsGetLine * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: Buffer - Where to store the line * * RETURN: Actual bytes read * @@ -581,10 +590,10 @@ AcpiOsGetLine ( * * FUNCTION: AcpiOsMapMemory * - * PARAMETERS: where Physical address of memory to be mapped - * length How much memory to map + * PARAMETERS: Where - Physical address of memory to be mapped + * Length - How much memory to map * - * RETURN: Pointer to mapped memory. Null on error. + * RETURN: Pointer to mapped memory. Null on error. * * DESCRIPTION: Map physical memory into caller's address space * @@ -592,11 +601,11 @@ AcpiOsGetLine ( void * AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS where, - ACPI_SIZE length) + ACPI_PHYSICAL_ADDRESS Where, + ACPI_SIZE Length) { - return (ACPI_TO_POINTER ((ACPI_SIZE) where)); + return (ACPI_TO_POINTER ((ACPI_SIZE) Where)); } @@ -604,20 +613,20 @@ AcpiOsMapMemory ( * * FUNCTION: AcpiOsUnmapMemory * - * PARAMETERS: where Logical address of memory to be unmapped - * length How much memory to unmap + * PARAMETERS: Where - Logical address of memory to be unmapped + * Length - How much memory to unmap * * RETURN: None. * - * DESCRIPTION: Delete a previously created mapping. Where and Length must + * DESCRIPTION: Delete a previously created mapping. Where and Length must * correspond to a previous mapping exactly. * *****************************************************************************/ void AcpiOsUnmapMemory ( - void *where, - ACPI_SIZE length) + void *Where, + ACPI_SIZE Length) { return; @@ -628,24 +637,24 @@ AcpiOsUnmapMemory ( * * FUNCTION: AcpiOsAllocate * - * PARAMETERS: Size Amount to allocate, in bytes + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/ void * AcpiOsAllocate ( - ACPI_SIZE size) + ACPI_SIZE Size) { void *Mem; - Mem = (void *) malloc ((size_t) size); + Mem = (void *) malloc ((size_t) Size); - return Mem; + return (Mem); } @@ -653,7 +662,7 @@ AcpiOsAllocate ( * * FUNCTION: AcpiOsFree * - * PARAMETERS: mem Pointer to previously allocated memory + * PARAMETERS: Mem - Pointer to previously allocated memory * * RETURN: None. * @@ -670,6 +679,52 @@ AcpiOsFree ( } +#ifdef ACPI_SINGLE_THREADED +/****************************************************************************** + * + * FUNCTION: Semaphore stub functions + * + * DESCRIPTION: Stub functions used for single-thread applications that do + * not require semaphore synchronization. Full implementations + * of these functions appear after the stubs. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + *OutHandle = (ACPI_HANDLE) 1; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + return (AE_OK); +} + +#else /****************************************************************************** * * FUNCTION: AcpiOsCreateSemaphore @@ -690,12 +745,10 @@ AcpiOsCreateSemaphore ( UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle) { -#ifdef _MULTI_THREADED void *Mutex; UINT32 i; ACPI_FUNCTION_NAME (OsCreateSemaphore); -#endif if (MaxUnits == ACPI_UINT32_MAX) @@ -710,11 +763,9 @@ AcpiOsCreateSemaphore ( if (InitialUnits > MaxUnits) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } -#ifdef _MULTI_THREADED - /* Find an empty slot */ for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++) @@ -727,8 +778,8 @@ AcpiOsCreateSemaphore ( if (i >= ACPI_OS_MAX_SEMAPHORES) { ACPI_EXCEPTION ((AE_INFO, AE_LIMIT, - "Reached max semaphores (%d), could not create", ACPI_OS_MAX_SEMAPHORES)); - return AE_LIMIT; + "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES)); + return (AE_LIMIT); } /* Create an OS semaphore */ @@ -737,20 +788,18 @@ AcpiOsCreateSemaphore ( if (!Mutex) { ACPI_ERROR ((AE_INFO, "Could not create semaphore")); - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits; AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits; AcpiGbl_Semaphores[i].OsHandle = Mutex; - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%d, Max=%d, Current=%d, OsHandle=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n", i, MaxUnits, InitialUnits, Mutex)); *OutHandle = (void *) i; -#endif - - return AE_OK; + return (AE_OK); } @@ -776,17 +825,12 @@ AcpiOsDeleteSemaphore ( if ((Index >= ACPI_OS_MAX_SEMAPHORES) || !AcpiGbl_Semaphores[Index].OsHandle) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - -#ifdef _MULTI_THREADED - CloseHandle (AcpiGbl_Semaphores[Index].OsHandle); AcpiGbl_Semaphores[Index].OsHandle = NULL; -#endif - - return AE_OK; + return (AE_OK); } @@ -810,7 +854,6 @@ AcpiOsWaitSemaphore ( UINT32 Units, UINT16 Timeout) { -#ifdef _MULTI_THREADED UINT32 Index = (UINT32) Handle; UINT32 WaitStatus; UINT32 OsTimeout = Timeout; @@ -822,13 +865,13 @@ AcpiOsWaitSemaphore ( if ((Index >= ACPI_OS_MAX_SEMAPHORES) || !AcpiGbl_Semaphores[Index].OsHandle) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (Units > 1) { - printf ("WaitSemaphore: Attempt to receive %d units\n", Units); - return AE_NOT_IMPLEMENTED; + printf ("WaitSemaphore: Attempt to receive %u units\n", Units); + return (AE_NOT_IMPLEMENTED); } if (Timeout == ACPI_WAIT_FOREVER) @@ -857,21 +900,19 @@ AcpiOsWaitSemaphore ( "Debug timeout on semaphore 0x%04X (%ums)\n", Index, ACPI_OS_DEBUG_TIMEOUT)); } - return AE_TIME; + return (AE_TIME); } if (AcpiGbl_Semaphores[Index].CurrentUnits == 0) { - ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout %X, OSstatus 0x%X", + ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X", AcpiUtGetMutexName (Index), Timeout, WaitStatus)); - return AE_OK; + return (AE_OK); } AcpiGbl_Semaphores[Index].CurrentUnits--; -#endif - - return AE_OK; + return (AE_OK); } @@ -893,8 +934,6 @@ AcpiOsSignalSemaphore ( ACPI_SEMAPHORE Handle, UINT32 Units) { -#ifdef _MULTI_THREADED - UINT32 Index = (UINT32) Handle; @@ -904,26 +943,26 @@ AcpiOsSignalSemaphore ( if (Index >= ACPI_OS_MAX_SEMAPHORES) { printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (!AcpiGbl_Semaphores[Index].OsHandle) { printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (Units > 1) { - printf ("SignalSemaphore: Attempt to signal %d units, Index %2.2X\n", Units, Index); - return AE_NOT_IMPLEMENTED; + printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index); + return (AE_NOT_IMPLEMENTED); } if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) > AcpiGbl_Semaphores[Index].MaxUnits) { ACPI_ERROR ((AE_INFO, - "Oversignalled semaphore[%d]! Current %d Max %d", + "Oversignalled semaphore[%u]! Current %u Max %u", Index, AcpiGbl_Semaphores[Index].CurrentUnits, AcpiGbl_Semaphores[Index].MaxUnits)); @@ -933,13 +972,19 @@ AcpiOsSignalSemaphore ( AcpiGbl_Semaphores[Index].CurrentUnits++; ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL); -#endif - return (AE_OK); } +#endif /* ACPI_SINGLE_THREADED */ -/* Spinlock interfaces, just implement with a semaphore */ + +/****************************************************************************** + * + * FUNCTION: Spinlock interfaces + * + * DESCRIPTION: Map these interfaces to semaphore interfaces + * + *****************************************************************************/ ACPI_STATUS AcpiOsCreateLock ( @@ -1012,13 +1057,13 @@ AcpiOsReleaseMutex ( * * FUNCTION: AcpiOsInstallInterruptHandler * - * PARAMETERS: InterruptNumber Level handler should respond to. - * Isr Address of the ACPI interrupt handler - * ExceptPtr Where status is returned + * PARAMETERS: InterruptNumber - Level handler should respond to. + * ServiceRoutine - Address of the ACPI interrupt handler + * Context - User context * * RETURN: Handle to the newly installed handler. * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI + * DESCRIPTION: Install an interrupt handler. Used to install the ACPI * OS-independent handler. * *****************************************************************************/ @@ -1030,7 +1075,7 @@ AcpiOsInstallInterruptHandler ( void *Context) { - return AE_OK; + return (AE_OK); } @@ -1038,7 +1083,7 @@ AcpiOsInstallInterruptHandler ( * * FUNCTION: AcpiOsRemoveInterruptHandler * - * PARAMETERS: Handle Returned when handler was installed + * PARAMETERS: Handle - Returned when handler was installed * * RETURN: Status * @@ -1052,7 +1097,7 @@ AcpiOsRemoveInterruptHandler ( ACPI_OSD_HANDLER ServiceRoutine) { - return AE_OK; + return (AE_OK); } @@ -1077,7 +1122,7 @@ AcpiOsGetThreadId ( /* Ensure ID is never 0 */ ThreadId = GetCurrentThreadId (); - return (ThreadId + 1); + return ((ACPI_THREAD_ID) (ThreadId + 1)); } @@ -1085,9 +1130,9 @@ AcpiOsGetThreadId ( * * FUNCTION: AcpiOsExecute * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function * * RETURN: Status * @@ -1102,11 +1147,11 @@ AcpiOsExecute ( void *Context) { -#ifdef _MULTI_THREADED +#ifndef ACPI_SINGLE_THREADED _beginthread (Function, (unsigned) 0, Context); #endif - return 0; + return (0); } @@ -1114,9 +1159,9 @@ AcpiOsExecute ( * * FUNCTION: AcpiOsStall * - * PARAMETERS: microseconds To sleep + * PARAMETERS: Microseconds - Time to stall * - * RETURN: Blocks until sleep is completed. + * RETURN: None. Blocks until stall is completed. * * DESCRIPTION: Sleep at microsecond granularity * @@ -1124,10 +1169,10 @@ AcpiOsExecute ( void AcpiOsStall ( - UINT32 microseconds) + UINT32 Microseconds) { - Sleep ((microseconds / 1000) + 1); + Sleep ((Microseconds / 1000) + 1); return; } @@ -1136,9 +1181,9 @@ AcpiOsStall ( * * FUNCTION: AcpiOsSleep * - * PARAMETERS: milliseconds To sleep + * PARAMETERS: Milliseconds - Time to sleep * - * RETURN: Blocks until sleep is completed. + * RETURN: None. Blocks until sleep is completed. * * DESCRIPTION: Sleep at millisecond granularity * @@ -1146,46 +1191,24 @@ AcpiOsStall ( void AcpiOsSleep ( - ACPI_INTEGER milliseconds) + UINT64 Milliseconds) { /* Add 10ms to account for clock tick granularity */ - Sleep (((unsigned long) milliseconds) + 10); + Sleep (((unsigned long) Milliseconds) + 10); return; } -/****************************************************************************** - * - * FUNCTION: AcpiOsValidateInterface - * - * PARAMETERS: Interface - Requested interface to be validated - * - * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise - * - * DESCRIPTION: Match an interface string to the interfaces supported by the - * host. Strings originate from an AML call to the _OSI method. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsValidateInterface ( - char *Interface) -{ - - return (AE_SUPPORT); -} - - /****************************************************************************** * * FUNCTION: AcpiOsReadPciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Buffer where value is placed - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Buffer where value is placed + * Width - Number of bits * * RETURN: Status * @@ -1197,7 +1220,7 @@ ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - void *Value, + UINT64 *Value, UINT32 Width) { @@ -1209,12 +1232,12 @@ AcpiOsReadPciConfiguration ( * * FUNCTION: AcpiOsWritePciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Value to be written - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Value to be written + * Width - Number of bits * - * RETURN: Status. + * RETURN: Status * * DESCRIPTION: Write data to PCI configuration space * @@ -1224,32 +1247,21 @@ ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - ACPI_INTEGER Value, + UINT64 Value, UINT32 Width) { return (AE_OK); } -/* TEMPORARY STUB FUNCTION */ -void -AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, - ACPI_PCI_ID **PciId) -{ - - return; -} - /****************************************************************************** * * FUNCTION: AcpiOsReadPort * - * PARAMETERS: Address Address of I/O port/register to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from port * @@ -1290,9 +1302,9 @@ AcpiOsReadPort ( * * FUNCTION: AcpiOsWritePort * - * PARAMETERS: Address Address of I/O port/register to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1315,11 +1327,11 @@ AcpiOsWritePort ( * * FUNCTION: AcpiOsReadMemory * - * PARAMETERS: Address Physical Memory Address to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to read + * Value - Where value is placed + * Width - Number of bits * - * RETURN: Value read from physical memory address. Always returned + * RETURN: Value read from physical memory address. Always returned * as a 32-bit integer, regardless of the read width. * * DESCRIPTION: Read data from a physical memory address @@ -1354,9 +1366,9 @@ AcpiOsReadMemory ( * * FUNCTION: AcpiOsWriteMemory * - * PARAMETERS: Address Physical Memory Address to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1379,8 +1391,8 @@ AcpiOsWriteMemory ( * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function ACPI CA signal function code - * Info Pointer to function-dependent structure + * PARAMETERS: Function - ACPI CA signal function code + * Info - Pointer to function-dependent structure * * RETURN: Status * @@ -1409,3 +1421,78 @@ AcpiOsSignal ( return (AE_OK); } + +/****************************************************************************** + * + * FUNCTION: Local cache interfaces + * + * DESCRIPTION: Implements cache interfaces via malloc/free for testing + * purposes only. + * + *****************************************************************************/ + +#ifndef ACPI_USE_LOCAL_CACHE + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + ACPI_MEMORY_LIST *NewCache; + + + NewCache = malloc (sizeof (ACPI_MEMORY_LIST)); + if (!NewCache) + { + return (AE_NO_MEMORY); + } + + memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST)); + NewCache->LinkOffset = 8; + NewCache->ListName = CacheName; + NewCache->ObjectSize = ObjectSize; + NewCache->MaxDepth = MaxDepth; + + *ReturnCache = (ACPI_CACHE_T) NewCache; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + free (Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + void *NewObject; + + NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize); + memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize); + + return (NewObject); +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + free (Object); + return (AE_OK); +} + +#endif diff --git a/sys/contrib/dev/acpica-unix/osunixxf.c b/sys/contrib/dev/acpica-unix/osunixxf.c index b430e83f16..a9e3763a60 100644 --- a/sys/contrib/dev/acpica-unix/osunixxf.c +++ b/sys/contrib/dev/acpica-unix/osunixxf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -115,10 +115,11 @@ /* - * These interfaces are required in order to compile the ASL compiler under - * Linux or other Unix-like system. + * These interfaces are required in order to compile the ASL compiler and the + * various ACPICA tools under Linux or other Unix-like system. + * + * Note: Use #define __APPLE__ for OS X generation. */ - #include #include #include @@ -126,6 +127,7 @@ #include #include #include +#include #include "acpi.h" #include "accommon.h" @@ -154,6 +156,12 @@ AeTableOverride ( typedef void* (*PTHREAD_CALLBACK) (void *); +/* Apple-specific */ + +#ifdef __APPLE__ +#define sem_destroy sem_close +#endif + /****************************************************************************** * @@ -163,12 +171,13 @@ typedef void* (*PTHREAD_CALLBACK) (void *); * * RETURN: Status * - * DESCRIPTION: Init and terminate. Nothing to do. + * DESCRIPTION: Init and terminate. Nothing to do. * *****************************************************************************/ ACPI_STATUS -AcpiOsInitialize (void) +AcpiOsInitialize ( + void) { AcpiGbl_OutputFile = stdout; @@ -177,7 +186,8 @@ AcpiOsInitialize (void) ACPI_STATUS -AcpiOsTerminate (void) +AcpiOsTerminate ( + void) { return (AE_OK); @@ -192,7 +202,7 @@ AcpiOsTerminate (void) * * RETURN: RSDP physical address * - * DESCRIPTION: Gets the root pointer (RSDP) + * DESCRIPTION: Gets the ACPI root pointer (RSDP) * *****************************************************************************/ @@ -209,10 +219,10 @@ AcpiOsGetRootPointer ( * * FUNCTION: AcpiOsPredefinedOverride * - * PARAMETERS: InitVal - Initial value of the predefined object - * NewVal - The new value for the object + * PARAMETERS: InitVal - Initial value of the predefined object + * NewVal - The new value for the object * - * RETURN: Status, pointer to value. Null pointer returned if not + * RETURN: Status, pointer to value. Null pointer returned if not * overriding. * * DESCRIPTION: Allow the OS to override predefined names @@ -239,10 +249,11 @@ AcpiOsPredefinedOverride ( * * FUNCTION: AcpiOsTableOverride * - * PARAMETERS: ExistingTable - Header of current table (probably firmware) - * NewTable - Where an entire new table is returned. + * PARAMETERS: ExistingTable - Header of current table (probably + * firmware) + * NewTable - Where an entire new table is returned. * - * RETURN: Status, pointer to new table. Null pointer returned if no + * RETURN: Status, pointer to new table. Null pointer returned if no * table is available to override * * DESCRIPTION: Return a different version of a table if one is available @@ -298,7 +309,7 @@ AcpiOsRedirectOutput ( * * FUNCTION: AcpiOsPrintf * - * PARAMETERS: fmt, ... Standard printf format + * PARAMETERS: fmt, ... - Standard printf format * * RETURN: None * @@ -324,8 +335,8 @@ AcpiOsPrintf ( * * FUNCTION: AcpiOsVprintf * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: fmt - Standard printf format + * args - Argument list * * RETURN: None * @@ -372,8 +383,8 @@ AcpiOsVprintf ( * * FUNCTION: AcpiOsGetLine * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: fmt - Standard printf format + * args - Argument list * * RETURN: Actual bytes read * @@ -409,14 +420,15 @@ AcpiOsGetLine ( return (i); } + /****************************************************************************** * * FUNCTION: AcpiOsMapMemory * - * PARAMETERS: where Physical address of memory to be mapped - * length How much memory to map + * PARAMETERS: where - Physical address of memory to be mapped + * length - How much memory to map * - * RETURN: Pointer to mapped memory. Null on error. + * RETURN: Pointer to mapped memory. Null on error. * * DESCRIPTION: Map physical memory into caller's address space * @@ -436,12 +448,12 @@ AcpiOsMapMemory ( * * FUNCTION: AcpiOsUnmapMemory * - * PARAMETERS: where Logical address of memory to be unmapped - * length How much memory to unmap + * PARAMETERS: where - Logical address of memory to be unmapped + * length - How much memory to unmap * * RETURN: None. * - * DESCRIPTION: Delete a previously created mapping. Where and Length must + * DESCRIPTION: Delete a previously created mapping. Where and Length must * correspond to a previous mapping exactly. * *****************************************************************************/ @@ -460,11 +472,11 @@ AcpiOsUnmapMemory ( * * FUNCTION: AcpiOsAllocate * - * PARAMETERS: Size Amount to allocate, in bytes + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/ @@ -484,7 +496,7 @@ AcpiOsAllocate ( * * FUNCTION: AcpiOsFree * - * PARAMETERS: mem Pointer to previously allocated memory + * PARAMETERS: mem - Pointer to previously allocated memory * * RETURN: None. * @@ -501,6 +513,52 @@ AcpiOsFree ( } +#ifdef ACPI_SINGLE_THREADED +/****************************************************************************** + * + * FUNCTION: Semaphore stub functions + * + * DESCRIPTION: Stub functions used for single-thread applications that do + * not require semaphore synchronization. Full implementations + * of these functions appear after the stubs. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + *OutHandle = (ACPI_HANDLE) 1; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + return (AE_OK); +} + +#else /****************************************************************************** * * FUNCTION: AcpiOsCreateSemaphore @@ -528,8 +586,20 @@ AcpiOsCreateSemaphore ( return (AE_BAD_PARAMETER); } - Sem = AcpiOsAllocate (sizeof (sem_t)); +#ifdef __APPLE__ + { + char *SemaphoreName = tmpnam (NULL); + Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); + if (!Sem) + { + return (AE_NO_MEMORY); + } + sem_unlink (SemaphoreName); /* This just deletes the name */ + } + +#else + Sem = AcpiOsAllocate (sizeof (sem_t)); if (!Sem) { return (AE_NO_MEMORY); @@ -540,6 +610,7 @@ AcpiOsCreateSemaphore ( AcpiOsFree (Sem); return (AE_BAD_PARAMETER); } +#endif *OutHandle = (ACPI_HANDLE) Sem; return (AE_OK); @@ -708,6 +779,8 @@ AcpiOsSignalSemaphore ( return (AE_OK); } +#endif /* ACPI_SINGLE_THREADED */ + /****************************************************************************** * @@ -756,13 +829,13 @@ AcpiOsReleaseLock ( * * FUNCTION: AcpiOsInstallInterruptHandler * - * PARAMETERS: InterruptNumber Level handler should respond to. - * Isr Address of the ACPI interrupt handler - * ExceptPtr Where status is returned + * PARAMETERS: InterruptNumber - Level handler should respond to. + * Isr - Address of the ACPI interrupt handler + * ExceptPtr - Where status is returned * * RETURN: Handle to the newly installed handler. * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI + * DESCRIPTION: Install an interrupt handler. Used to install the ACPI * OS-independent handler. * *****************************************************************************/ @@ -782,7 +855,7 @@ AcpiOsInstallInterruptHandler ( * * FUNCTION: AcpiOsRemoveInterruptHandler * - * PARAMETERS: Handle Returned when handler was installed + * PARAMETERS: Handle - Returned when handler was installed * * RETURN: Status * @@ -804,9 +877,9 @@ AcpiOsRemoveInterruptHandler ( * * FUNCTION: AcpiOsExecute * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function * * RETURN: Status. * @@ -837,7 +910,7 @@ AcpiOsExecute ( * * FUNCTION: AcpiOsStall * - * PARAMETERS: microseconds To sleep + * PARAMETERS: microseconds - Time to sleep * * RETURN: Blocks until sleep is completed. * @@ -861,7 +934,7 @@ AcpiOsStall ( * * FUNCTION: AcpiOsSleep * - * PARAMETERS: milliseconds To sleep + * PARAMETERS: milliseconds - Time to sleep * * RETURN: Blocks until sleep is completed. * @@ -871,7 +944,7 @@ AcpiOsStall ( void AcpiOsSleep ( - ACPI_INTEGER milliseconds) + UINT64 milliseconds) { sleep (milliseconds / 1000); /* Sleep for whole seconds */ @@ -882,6 +955,7 @@ AcpiOsSleep ( usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */ } + /****************************************************************************** * * FUNCTION: AcpiOsGetTimer @@ -895,7 +969,8 @@ AcpiOsSleep ( *****************************************************************************/ UINT64 -AcpiOsGetTimer (void) +AcpiOsGetTimer ( + void) { struct timeval time; @@ -908,36 +983,14 @@ AcpiOsGetTimer (void) } -/****************************************************************************** - * - * FUNCTION: AcpiOsValidateInterface - * - * PARAMETERS: Interface - Requested interface to be validated - * - * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise - * - * DESCRIPTION: Match an interface string to the interfaces supported by the - * host. Strings originate from an AML call to the _OSI method. - * - *****************************************************************************/ - -ACPI_STATUS -AcpiOsValidateInterface ( - char *Interface) -{ - - return (AE_SUPPORT); -} - - /****************************************************************************** * * FUNCTION: AcpiOsReadPciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Buffer where value is placed - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Buffer where value is placed + * Width - Number of bits * * RETURN: Status * @@ -949,7 +1002,7 @@ ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - void *Value, + UINT64 *Value, UINT32 Width) { @@ -961,10 +1014,10 @@ AcpiOsReadPciConfiguration ( * * FUNCTION: AcpiOsWritePciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Value to be written - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Value to be written + * Width - Number of bits * * RETURN: Status. * @@ -976,31 +1029,21 @@ ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Register, - ACPI_INTEGER Value, + UINT64 Value, UINT32 Width) { return (AE_OK); } -/* TEMPORARY STUB FUNCTION */ -void -AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, - ACPI_PCI_ID **PciId) -{ - -} - /****************************************************************************** * * FUNCTION: AcpiOsReadPort * - * PARAMETERS: Address Address of I/O port/register to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from port * @@ -1041,9 +1084,9 @@ AcpiOsReadPort ( * * FUNCTION: AcpiOsWritePort * - * PARAMETERS: Address Address of I/O port/register to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1066,9 +1109,9 @@ AcpiOsWritePort ( * * FUNCTION: AcpiOsReadMemory * - * PARAMETERS: Address Physical Memory Address to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from physical memory address * @@ -1102,9 +1145,9 @@ AcpiOsReadMemory ( * * FUNCTION: AcpiOsWriteMemory * - * PARAMETERS: Address Physical Memory Address to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1177,18 +1220,16 @@ AcpiOsWritable ( * * RETURN: Id of the running thread * - * DESCRIPTION: Get the Id of the current (running) thread - * - * NOTE: The environment header should contain this line: - * #define ACPI_THREAD_ID pthread_t + * DESCRIPTION: Get the ID of the current (running) thread * *****************************************************************************/ ACPI_THREAD_ID -AcpiOsGetThreadId (void) +AcpiOsGetThreadId ( + void) { - return (pthread_self ()); + return (ACPI_CAST_PTHREAD_T (pthread_self())); } @@ -1196,8 +1237,8 @@ AcpiOsGetThreadId (void) * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function ACPI CA signal function code - * Info Pointer to function-dependent structure + * PARAMETERS: Function - ACPI CA signal function code + * Info - Pointer to function-dependent structure * * RETURN: Status * @@ -1225,5 +1266,3 @@ AcpiOsSignal ( return (AE_OK); } - - diff --git a/sys/contrib/dev/acpica-unix/parser/psargs.c b/sys/contrib/dev/acpica-unix/parser/psargs.c index 60d4a835b1..1dcb1b77b0 100644 --- a/sys/contrib/dev/acpica-unix/parser/psargs.c +++ b/sys/contrib/dev/acpica-unix/parser/psargs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -514,7 +514,7 @@ AcpiPsGetNextSimpleArg ( /* Get 1 byte from the AML stream */ Opcode = AML_BYTE_OP; - Arg->Common.Value.Integer = (ACPI_INTEGER) *Aml; + Arg->Common.Value.Integer = (UINT64) *Aml; Length = 1; break; @@ -577,7 +577,7 @@ AcpiPsGetNextSimpleArg ( default: - ACPI_ERROR ((AE_INFO, "Invalid ArgType %X", ArgType)); + ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType)); return_VOID; } @@ -883,7 +883,7 @@ AcpiPsGetNextArg ( default: - ACPI_ERROR ((AE_INFO, "Invalid ArgType: %X", ArgType)); + ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType)); Status = AE_AML_OPERAND_TYPE; break; } diff --git a/sys/contrib/dev/acpica-unix/parser/psloop.c b/sys/contrib/dev/acpica-unix/parser/psloop.c index a6f4344f77..9791efcc78 100644 --- a/sys/contrib/dev/acpica-unix/parser/psloop.c +++ b/sys/contrib/dev/acpica-unix/parser/psloop.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -171,6 +171,13 @@ AcpiPsCompleteFinalOp ( ACPI_PARSE_OBJECT *Op, ACPI_STATUS Status); +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId); + /******************************************************************************* * @@ -221,7 +228,7 @@ AcpiPsGetAmlOpcode ( /* The opcode is unrecognized. Just skip unknown opcodes */ ACPI_ERROR ((AE_INFO, - "Found unknown opcode %X at AML address %p offset %X, ignoring", + "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring", WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset)); ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128); @@ -502,6 +509,7 @@ AcpiPsGetArguments ( { ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); @@ -558,13 +566,11 @@ AcpiPsGetArguments ( } - /* Special processing for certain opcodes */ - - /* TBD (remove): Temporary mechanism to disable this code if needed */ - -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - - if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS1) && + /* + * Handle executable code at "module-level". This refers to + * executable opcodes that appear outside of any control method. + */ + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) && ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) { /* @@ -580,6 +586,19 @@ AcpiPsGetArguments ( case AML_ELSE_OP: case AML_WHILE_OP: + /* + * Currently supported module-level opcodes are: + * IF/ELSE/WHILE. These appear to be the most common, + * and easiest to support since they open an AML + * package. + */ + if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) + { + AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart, + (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart), + WalkState->OwnerId); + } + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Pass1: Skipping an If/Else/While body\n")); @@ -590,10 +609,33 @@ AcpiPsGetArguments ( break; default: + /* + * Check for an unsupported executable opcode at module + * level. We must be in PASS1, the parent must be a SCOPE, + * The opcode class must be EXECUTE, and the opcode must + * not be an argument to another opcode. + */ + if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) && + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (!Arg)) + { + ACPI_WARNING ((AE_INFO, + "Detected an unsupported executable opcode " + "at module-level: [0x%.4X] at table offset 0x%.4X", + Op->Common.AmlOpcode, + (UINT32) (ACPI_PTR_DIFF (AmlOpStart, + WalkState->ParserState.AmlStart) + + sizeof (ACPI_TABLE_HEADER)))); + } + } break; } } -#endif + + /* Special processing for certain opcodes */ switch (Op->Common.AmlOpcode) { @@ -659,6 +701,97 @@ AcpiPsGetArguments ( } +/******************************************************************************* + * + * FUNCTION: AcpiPsLinkModuleCode + * + * PARAMETERS: ParentOp - Parent parser op + * AmlStart - Pointer to the AML + * AmlLength - Length of executable AML + * OwnerId - OwnerId of module level code + * + * RETURN: None. + * + * DESCRIPTION: Wrap the module-level code with a method object and link the + * object to the global list. Note, the mutex field of the method + * object is used to link multiple module-level code objects. + * + ******************************************************************************/ + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Get the tail of the list */ + + Prev = Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + } + + /* + * Insert the module level code into the list. Merge it if it is + * adjacent to the previous element. + */ + if (!Prev || + ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart)) + { + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return; + } + + if (ParentOp->Common.Node) + { + ParentNode = ParentOp->Common.Node; + } + else + { + ParentNode = AcpiGbl_RootNode; + } + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL; + + /* + * Save the parent node in NextObject. This is cheating, but we + * don't want to expand the method object. + */ + MethodObj->Method.NextObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode); + + if (!Prev) + { + AcpiGbl_ModuleCodeList = MethodObj; + } + else + { + Prev->Method.Mutex = MethodObj; + } + } + else + { + Prev->Method.AmlLength += AmlLength; + } +} + + /******************************************************************************* * * FUNCTION: AcpiPsCompleteOp @@ -1016,7 +1149,6 @@ AcpiPsParseLoop ( { ACPI_EXCEPTION ((AE_INFO, Status, "Invoked method did not return a value")); - } ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); diff --git a/sys/contrib/dev/acpica-unix/parser/psopcode.c b/sys/contrib/dev/acpica-unix/parser/psopcode.c index d107c52370..30a393f1ef 100644 --- a/sys/contrib/dev/acpica-unix/parser/psopcode.c +++ b/sys/contrib/dev/acpica-unix/parser/psopcode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/parser/psparse.c b/sys/contrib/dev/acpica-unix/parser/psparse.c index d9d6a2944b..59af839bec 100644 --- a/sys/contrib/dev/acpica-unix/parser/psparse.c +++ b/sys/contrib/dev/acpica-unix/parser/psparse.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -128,7 +128,6 @@ #include "acparser.h" #include "acdispat.h" #include "amlcode.h" -#include "acnamesp.h" #include "acinterp.h" #define _COMPONENT ACPI_PARSER @@ -635,23 +634,16 @@ AcpiPsParseAml ( /* Check for possible multi-thread reentrancy problem */ if ((Status == AE_ALREADY_EXISTS) && - (!WalkState->MethodDesc->Method.Mutex)) + (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED))) { - ACPI_INFO ((AE_INFO, - "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", - WalkState->MethodNode->Name.Ascii)); - /* - * Method tried to create an object twice. The probable cause is - * that the method cannot handle reentrancy. - * - * The method is marked NotSerialized, but it tried to create - * a named object, causing the second thread entrance to fail. - * Workaround this problem by marking the method permanently - * as Serialized. + * Method is not serialized and tried to create an object + * twice. The probable cause is that the method cannot + * handle reentrancy. Mark as "pending serialized" now, and + * then mark "serialized" when the last thread exits. */ - WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; - WalkState->MethodDesc->Method.SyncLevel = 0; + WalkState->MethodDesc->Method.InfoFlags |= + ACPI_METHOD_SERIALIZED_PENDING; } } @@ -705,13 +697,11 @@ AcpiPsParseAml ( !PreviousWalkState->ImplicitReturnObj) { PreviousWalkState->ImplicitReturnObj = - AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + AcpiUtCreateIntegerObject ((UINT64) 0); if (!PreviousWalkState->ImplicitReturnObj) { return_ACPI_STATUS (AE_NO_MEMORY); } - - PreviousWalkState->ImplicitReturnObj->Integer.Value = 0; } /* Restart the calling control method */ diff --git a/sys/contrib/dev/acpica-unix/parser/psscope.c b/sys/contrib/dev/acpica-unix/parser/psscope.c index 979dbb1515..10fe18690f 100644 --- a/sys/contrib/dev/acpica-unix/parser/psscope.c +++ b/sys/contrib/dev/acpica-unix/parser/psscope.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/parser/pstree.c b/sys/contrib/dev/acpica-unix/parser/pstree.c index 20ac405cac..950dedf6c2 100644 --- a/sys/contrib/dev/acpica-unix/parser/pstree.c +++ b/sys/contrib/dev/acpica-unix/parser/pstree.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/parser/psutils.c b/sys/contrib/dev/acpica-unix/parser/psutils.c index a4ff03eba0..e676a4023a 100644 --- a/sys/contrib/dev/acpica-unix/parser/psutils.c +++ b/sys/contrib/dev/acpica-unix/parser/psutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -280,11 +280,11 @@ AcpiPsFreeOp ( if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) { - ACPI_OS_RELEASE_OBJECT(AcpiGbl_PsNodeCache, Op); + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op); } else { - ACPI_OS_RELEASE_OBJECT(AcpiGbl_PsNodeExtCache, Op); + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op); } } diff --git a/sys/contrib/dev/acpica-unix/parser/pswalk.c b/sys/contrib/dev/acpica-unix/parser/pswalk.c index d8d5f5e6f2..0de366c4a0 100644 --- a/sys/contrib/dev/acpica-unix/parser/pswalk.c +++ b/sys/contrib/dev/acpica-unix/parser/pswalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/parser/psxface.c b/sys/contrib/dev/acpica-unix/parser/psxface.c index d63abb6f4e..54af318284 100644 --- a/sys/contrib/dev/acpica-unix/parser/psxface.c +++ b/sys/contrib/dev/acpica-unix/parser/psxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,7 +120,7 @@ #include "acparser.h" #include "acdispat.h" #include "acinterp.h" -#include "amlcode.h" +#include "actables.h" #define _COMPONENT ACPI_PARSER @@ -334,6 +334,10 @@ AcpiPsExecuteMethod ( ACPI_FUNCTION_TRACE (PsExecuteMethod); + /* Quick validation of DSDT header */ + + AcpiTbCheckDsdtHeader (); + /* Validate the Info and method Node */ if (!Info || !Info->ResolvedNode) @@ -394,11 +398,16 @@ AcpiPsExecuteMethod ( goto Cleanup; } + if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + /* Invoke an internal method if necessary */ - if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY) { - Status = Info->ObjDesc->Method.Implementation (WalkState); + Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState); Info->ReturnObject = WalkState->ReturnDesc; /* Cleanup states */ @@ -417,15 +426,13 @@ AcpiPsExecuteMethod ( if (AcpiGbl_EnableInterpreterSlack) { WalkState->ImplicitReturnObj = - AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + AcpiUtCreateIntegerObject ((UINT64) 0); if (!WalkState->ImplicitReturnObj) { Status = AE_NO_MEMORY; AcpiDsDeleteWalkState (WalkState); goto Cleanup; } - - WalkState->ImplicitReturnObj->Integer.Value = 0; } /* Parse the AML */ diff --git a/sys/contrib/dev/acpica-unix/resources/rsaddr.c b/sys/contrib/dev/acpica-unix/resources/rsaddr.c index f2f3c4421f..0ee032c799 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsaddr.c +++ b/sys/contrib/dev/acpica-unix/resources/rsaddr.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rscalc.c b/sys/contrib/dev/acpica-unix/resources/rscalc.c index 76aa44ff83..ceb8cd9215 100644 --- a/sys/contrib/dev/acpica-unix/resources/rscalc.c +++ b/sys/contrib/dev/acpica-unix/resources/rscalc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rscreate.c b/sys/contrib/dev/acpica-unix/resources/rscreate.c index e9c840b64e..11db3a44f1 100644 --- a/sys/contrib/dev/acpica-unix/resources/rscreate.c +++ b/sys/contrib/dev/acpica-unix/resources/rscreate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -270,7 +270,7 @@ AcpiRsCreatePciRoutingTable ( /* * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a - * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin, + * package that in turn contains an UINT64 Address, a UINT8 Pin, * a Name, and a UINT8 SourceIndex. */ TopObjectList = PackageObject->Package.Elements; @@ -301,7 +301,7 @@ AcpiRsCreatePciRoutingTable ( if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) { ACPI_ERROR ((AE_INFO, - "(PRT[%X]) Need sub-package, found %s", + "(PRT[%u]) Need sub-package, found %s", Index, AcpiUtGetObjectTypeName (*TopObjectList))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -311,7 +311,7 @@ AcpiRsCreatePciRoutingTable ( if ((*TopObjectList)->Package.Count != 4) { ACPI_ERROR ((AE_INFO, - "(PRT[%X]) Need package of length 4, found length %d", + "(PRT[%u]) Need package of length 4, found length %u", Index, (*TopObjectList)->Package.Count)); return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); } @@ -328,7 +328,7 @@ AcpiRsCreatePciRoutingTable ( ObjDesc = SubObjectList[0]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { - ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", + ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } @@ -340,7 +340,7 @@ AcpiRsCreatePciRoutingTable ( ObjDesc = SubObjectList[1]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { - ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", + ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } @@ -378,7 +378,7 @@ AcpiRsCreatePciRoutingTable ( if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) { ACPI_ERROR ((AE_INFO, - "(PRT[%X].Source) Need name, found Reference Class %X", + "(PRT[%u].Source) Need name, found Reference Class 0x%X", Index, ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_BAD_DATA); } @@ -426,7 +426,7 @@ AcpiRsCreatePciRoutingTable ( default: ACPI_ERROR ((AE_INFO, - "(PRT[%X].Source) Need Ref/String/Integer, found %s", + "(PRT[%u].Source) Need Ref/String/Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } @@ -442,7 +442,7 @@ AcpiRsCreatePciRoutingTable ( if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, - "(PRT[%X].SourceIndex) Need Integer, found %s", + "(PRT[%u].SourceIndex) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } diff --git a/sys/contrib/dev/acpica-unix/resources/rsdump.c b/sys/contrib/dev/acpica-unix/resources/rsdump.c index 62db284c6f..d2db725b2e 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsdump.c +++ b/sys/contrib/dev/acpica-unix/resources/rsdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rsinfo.c b/sys/contrib/dev/acpica-unix/resources/rsinfo.c index abf79943d9..5fca428e3d 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsinfo.c +++ b/sys/contrib/dev/acpica-unix/resources/rsinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rsio.c b/sys/contrib/dev/acpica-unix/resources/rsio.c index fb9213dd72..26e7988644 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsio.c +++ b/sys/contrib/dev/acpica-unix/resources/rsio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rsirq.c b/sys/contrib/dev/acpica-unix/resources/rsirq.c index 7eab435139..d424d1215c 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsirq.c +++ b/sys/contrib/dev/acpica-unix/resources/rsirq.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rslist.c b/sys/contrib/dev/acpica-unix/resources/rslist.c index 3adce2b393..58bd395114 100644 --- a/sys/contrib/dev/acpica-unix/resources/rslist.c +++ b/sys/contrib/dev/acpica-unix/resources/rslist.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -174,7 +174,7 @@ AcpiRsConvertAmlToResources ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Could not convert AML resource (Type %X)", *Aml)); + "Could not convert AML resource (Type 0x%X)", *Aml)); return_ACPI_STATUS (Status); } @@ -232,7 +232,7 @@ AcpiRsConvertResourcesToAml ( if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) { ACPI_ERROR ((AE_INFO, - "Invalid descriptor type (%X) in resource list", + "Invalid descriptor type (0x%X) in resource list", Resource->Type)); return_ACPI_STATUS (AE_BAD_DATA); } @@ -245,7 +245,7 @@ AcpiRsConvertResourcesToAml ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Could not convert resource (type %X) to AML", + "Could not convert resource (type 0x%X) to AML", Resource->Type)); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica-unix/resources/rsmemory.c b/sys/contrib/dev/acpica-unix/resources/rsmemory.c index a3d08c01a1..708e604c51 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsmemory.c +++ b/sys/contrib/dev/acpica-unix/resources/rsmemory.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rsmisc.c b/sys/contrib/dev/acpica-unix/resources/rsmisc.c index 3565334e73..89c59a531b 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsmisc.c +++ b/sys/contrib/dev/acpica-unix/resources/rsmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -171,7 +171,7 @@ AcpiRsConvertAmlToResource ( /* Each internal resource struct is expected to be 32-bit aligned */ ACPI_WARNING ((AE_INFO, - "Misaligned resource pointer (get): %p Type %2.2X Len %X", + "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u", Resource, Resource->Type, Resource->Length)); } @@ -659,7 +659,7 @@ Exit: * "IRQ Format"), so 0x00 and 0x09 are illegal. */ ACPI_ERROR ((AE_INFO, - "Invalid interrupt polarity/trigger in resource list, %X", + "Invalid interrupt polarity/trigger in resource list, 0x%X", Aml->Irq.Flags)); return_ACPI_STATUS (AE_BAD_DATA); } diff --git a/sys/contrib/dev/acpica-unix/resources/rsutils.c b/sys/contrib/dev/acpica-unix/resources/rsutils.c index 4e0f04ce8e..f3c73f8fd4 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsutils.c +++ b/sys/contrib/dev/acpica-unix/resources/rsutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/resources/rsxface.c b/sys/contrib/dev/acpica-unix/resources/rsxface.c index 32ed559569..6646ef18ed 100644 --- a/sys/contrib/dev/acpica-unix/resources/rsxface.c +++ b/sys/contrib/dev/acpica-unix/resources/rsxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -191,7 +191,7 @@ AcpiRsValidateParameters ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - Node = AcpiNsMapHandleToNode (DeviceHandle); + Node = AcpiNsValidateHandle (DeviceHandle); if (!Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); diff --git a/sys/contrib/dev/acpica-unix/tables/tbfadt.c b/sys/contrib/dev/acpica-unix/tables/tbfadt.c index c657a0b75a..fae6428582 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbfadt.c +++ b/sys/contrib/dev/acpica-unix/tables/tbfadt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,7 +124,7 @@ /* Local prototypes */ -static inline void +static ACPI_INLINE void AcpiTbInitGenericAddress ( ACPI_GENERIC_ADDRESS *GenericAddress, UINT8 SpaceId, @@ -273,7 +273,7 @@ static ACPI_FADT_PM_INFO FadtPmInfoTable[] = * ******************************************************************************/ -static inline void +static ACPI_INLINE void AcpiTbInitGenericAddress ( ACPI_GENERIC_ADDRESS *GenericAddress, UINT8 SpaceId, @@ -388,7 +388,7 @@ AcpiTbCreateLocalFadt ( { ACPI_WARNING ((AE_INFO, "FADT (revision %u) is longer than ACPI 2.0 version, " - "truncating length 0x%X to 0x%X", + "truncating length %u to %u", Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); } @@ -482,8 +482,11 @@ AcpiTbConvertFadt ( * * The ACPI 1.0 reserved fields that will be zeroed are the bytes located * at offset 45, 55, 95, and the word located at offset 109, 110. + * + * Note: The FADT revision value is unreliable. Only the length can be + * trusted. */ - if (AcpiGbl_FADT.Header.Revision < 3) + if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE) { AcpiGbl_FADT.PreferredProfile = 0; AcpiGbl_FADT.PstateControl = 0; @@ -521,7 +524,7 @@ AcpiTbConvertFadt ( (Address64->Address != (UINT64) Address32)) { ACPI_ERROR ((AE_INFO, - "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32", FadtInfoTable[i].Name, Address32, ACPI_FORMAT_UINT64 (Address64->Address))); } @@ -582,7 +585,7 @@ AcpiTbValidateFadt ( { ACPI_WARNING ((AE_INFO, "32/64X FACS address mismatch in FADT - " - "%8.8X/%8.8X%8.8X, using 32", + "0x%8.8X/0x%8.8X%8.8X, using 32", AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; @@ -593,7 +596,7 @@ AcpiTbValidateFadt ( { ACPI_WARNING ((AE_INFO, "32/64X DSDT address mismatch in FADT - " - "%8.8X/%8.8X%8.8X, using 32", + "0x%8.8X/0x%8.8X%8.8X, using 32", AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; @@ -621,7 +624,7 @@ AcpiTbValidateFadt ( (Address64->BitWidth != ACPI_MUL_8 (Length))) { ACPI_WARNING ((AE_INFO, - "32/64X length mismatch in %s: %d/%d", + "32/64X length mismatch in %s: %u/%u", Name, ACPI_MUL_8 (Length), Address64->BitWidth)); } @@ -635,7 +638,7 @@ AcpiTbValidateFadt ( { ACPI_ERROR ((AE_INFO, "Required field %s has zero address and/or length:" - " %8.8X%8.8X/%X", + " 0x%8.8X%8.8X/0x%X", Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } @@ -651,7 +654,7 @@ AcpiTbValidateFadt ( { ACPI_WARNING ((AE_INFO, "Optional field %s has zero address or length: " - "%8.8X%8.8X/%X", + "0x%8.8X%8.8X/0x%X", Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } @@ -702,7 +705,7 @@ AcpiTbSetupFadtRegisters ( (FadtInfoTable[i].DefaultLength != Target64->BitWidth)) { ACPI_WARNING ((AE_INFO, - "Invalid length for %s: %d, using default %d", + "Invalid length for %s: %u, using default %u", FadtInfoTable[i].Name, Target64->BitWidth, FadtInfoTable[i].DefaultLength)); diff --git a/sys/contrib/dev/acpica-unix/tables/tbfind.c b/sys/contrib/dev/acpica-unix/tables/tbfind.c index 1838b5eb78..48ef81756c 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbfind.c +++ b/sys/contrib/dev/acpica-unix/tables/tbfind.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -164,7 +164,7 @@ AcpiTbFindTable ( /* Search for the table */ - for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), Header.Signature, ACPI_NAME_SIZE)) diff --git a/sys/contrib/dev/acpica-unix/tables/tbinstal.c b/sys/contrib/dev/acpica-unix/tables/tbinstal.c index c911f84f68..63f5f29e17 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbinstal.c +++ b/sys/contrib/dev/acpica-unix/tables/tbinstal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -227,7 +227,7 @@ AcpiTbAddTable ( /* Check if table is already registered */ - for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if (!AcpiGbl_RootTableList.Tables[i].Pointer) { @@ -370,7 +370,7 @@ AcpiTbResizeRootTableList ( /* Increase the Table Array size */ Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof (ACPI_TABLE_DESC)); if (!Tables) @@ -384,7 +384,7 @@ AcpiTbResizeRootTableList ( if (AcpiGbl_RootTableList.Tables) { ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, - (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); + (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC)); if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) { @@ -393,7 +393,7 @@ AcpiTbResizeRootTableList ( } AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT; AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; return_ACPI_STATUS (AE_OK); @@ -423,12 +423,14 @@ AcpiTbStoreTable ( UINT8 Flags, UINT32 *TableIndex) { - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status; + ACPI_TABLE_DESC *NewTable; /* Ensure that there is room for the table in the Root Table List */ - if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) { Status = AcpiTbResizeRootTableList(); if (ACPI_FAILURE (Status)) @@ -437,21 +439,21 @@ AcpiTbStoreTable ( } } + NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount]; + /* Initialize added table */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags; + NewTable->Address = Address; + NewTable->Pointer = Table; + NewTable->Length = Length; + NewTable->OwnerId = 0; + NewTable->Flags = Flags; - ACPI_MOVE_32_TO_32 ( - &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), - Table->Signature); + ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature); - *TableIndex = AcpiGbl_RootTableList.Count; - AcpiGbl_RootTableList.Count++; - return (Status); + *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; + AcpiGbl_RootTableList.CurrentTableCount++; + return (AE_OK); } @@ -523,7 +525,7 @@ AcpiTbTerminate ( /* Delete the individual tables */ - for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); } @@ -539,7 +541,7 @@ AcpiTbTerminate ( AcpiGbl_RootTableList.Tables = NULL; AcpiGbl_RootTableList.Flags = 0; - AcpiGbl_RootTableList.Count = 0; + AcpiGbl_RootTableList.CurrentTableCount = 0; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -575,7 +577,7 @@ AcpiTbDeleteNamespaceByOwner ( return_ACPI_STATUS (Status); } - if (TableIndex >= AcpiGbl_RootTableList.Count) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { /* The table index does not exist */ @@ -634,7 +636,7 @@ AcpiTbAllocateOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { Status = AcpiUtAllocateOwnerId (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); @@ -668,7 +670,7 @@ AcpiTbReleaseOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { AcpiUtReleaseOwnerId ( &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); @@ -705,7 +707,7 @@ AcpiTbGetOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; Status = AE_OK; @@ -734,7 +736,7 @@ AcpiTbIsTableLoaded ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { IsLoaded = (BOOLEAN) (AcpiGbl_RootTableList.Tables[TableIndex].Flags & @@ -766,7 +768,7 @@ AcpiTbSetTableLoadedFlag ( { (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { if (IsLoaded) { diff --git a/sys/contrib/dev/acpica-unix/tables/tbutils.c b/sys/contrib/dev/acpica-unix/tables/tbutils.c index f4803a2e76..3cb3cc204c 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbutils.c +++ b/sys/contrib/dev/acpica-unix/tables/tbutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,16 @@ /* Local prototypes */ +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length); + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header); + static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry ( UINT8 *TableEntry, @@ -174,7 +184,7 @@ AcpiTbTablesLoaded ( void) { - if (AcpiGbl_RootTableList.Count >= 3) + if (AcpiGbl_RootTableList.CurrentTableCount >= 3) { return (TRUE); } @@ -183,6 +193,67 @@ AcpiTbTablesLoaded ( } +/******************************************************************************* + * + * FUNCTION: AcpiTbFixString + * + * PARAMETERS: String - String to be repaired + * Length - Maximum length + * + * RETURN: None + * + * DESCRIPTION: Replace every non-printable or non-ascii byte in the string + * with a question mark '?'. + * + ******************************************************************************/ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length) +{ + + while (Length && *String) + { + if (!ACPI_IS_PRINT (*String)) + { + *String = '?'; + } + String++; + Length--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCleanupTableHeader + * + * PARAMETERS: OutHeader - Where the cleaned header is returned + * Header - Input ACPI table header + * + * RETURN: Returns the cleaned header in OutHeader + * + * DESCRIPTION: Copy the table header and ensure that all "string" fields in + * the header consist of printable characters. + * + ******************************************************************************/ + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header) +{ + + ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + + AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); + AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE); +} + + /******************************************************************************* * * FUNCTION: AcpiTbPrintTableHeader @@ -201,6 +272,8 @@ AcpiTbPrintTableHeader ( ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER *Header) { + ACPI_TABLE_HEADER LocalHeader; + /* * The reason that the Address is cast to a void pointer is so that we @@ -218,23 +291,29 @@ AcpiTbPrintTableHeader ( { /* RSDP has no common fields */ + ACPI_MEMCPY (LocalHeader.OemId, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); + ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", ACPI_CAST_PTR (void, Address), (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, - ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId)); + LocalHeader.OemId)); } else { /* Standard ACPI table with full common header */ + AcpiTbCleanupTableHeader (&LocalHeader, Header); + ACPI_INFO ((AE_INFO, "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", - Header->Signature, ACPI_CAST_PTR (void, Address), - Header->Length, Header->Revision, Header->OemId, - Header->OemTableId, Header->OemRevision, Header->AslCompilerId, - Header->AslCompilerRevision)); + LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, + LocalHeader.OemTableId, LocalHeader.OemRevision, + LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); } } @@ -270,7 +349,7 @@ AcpiTbVerifyChecksum ( if (Checksum) { ACPI_WARNING ((AE_INFO, - "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", + "Incorrect checksum in table [%4.4s] - 0x%2.2X, should be 0x%2.2X", Table->Signature, Table->Checksum, (UINT8) (Table->Checksum - Checksum))); @@ -314,6 +393,88 @@ AcpiTbChecksum ( } +/******************************************************************************* + * + * FUNCTION: AcpiTbCheckDsdtHeader + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect + * if the DSDT has been replaced from outside the OS and/or if + * the DSDT header has been corrupted. + * + ******************************************************************************/ + +void +AcpiTbCheckDsdtHeader ( + void) +{ + + /* Compare original length and checksum to current values */ + + if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length || + AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum) + { + ACPI_ERROR ((AE_INFO, + "The DSDT has been corrupted or replaced - old, new headers below")); + AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader); + AcpiTbPrintTableHeader (0, AcpiGbl_DSDT); + + /* Disable further error messages */ + + AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length; + AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCopyDsdt + * + * PARAMETERS: TableDesc - Installed table to copy + * + * RETURN: None + * + * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory. + * Some very bad BIOSs are known to either corrupt the DSDT or + * install a new, bad DSDT. This copy works around the problem. + * + ******************************************************************************/ + +ACPI_TABLE_HEADER * +AcpiTbCopyDsdt ( + UINT32 TableIndex) +{ + ACPI_TABLE_HEADER *NewTable; + ACPI_TABLE_DESC *TableDesc; + + + TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex]; + + NewTable = ACPI_ALLOCATE (TableDesc->Length); + if (!NewTable) + { + ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X", + TableDesc->Length)); + return (NULL); + } + + ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length); + AcpiTbDeleteTable (TableDesc); + TableDesc->Pointer = NewTable; + TableDesc->Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + ACPI_INFO ((AE_INFO, + "Forced DSDT copy: length 0x%05X copied locally, original unmapped", + NewTable->Length)); + + return (NewTable); +} + + /******************************************************************************* * * FUNCTION: AcpiTbInstallTable @@ -473,7 +634,7 @@ AcpiTbGetRootTableEntry ( /* Will truncate 64-bit address to 32 bits, issue warning */ ACPI_WARNING ((AE_INFO, - "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X)," " truncating", ACPI_FORMAT_UINT64 (Address64))); } @@ -604,14 +765,15 @@ AcpiTbParseRootTable ( * come from the FADT */ TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); - AcpiGbl_RootTableList.Count = 2; + AcpiGbl_RootTableList.CurrentTableCount = 2; /* * Initialize the root table array from the RSDT/XSDT */ for (i = 0; i < TableCount; i++) { - if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) { /* There is no more room in the root table array, attempt resize */ @@ -620,18 +782,18 @@ AcpiTbParseRootTable ( { ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", (unsigned) (TableCount - - (AcpiGbl_RootTableList.Count - 2)))); + (AcpiGbl_RootTableList.CurrentTableCount - 2)))); break; } } /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); TableEntry += TableEntrySize; - AcpiGbl_RootTableList.Count++; + AcpiGbl_RootTableList.CurrentTableCount++; } /* @@ -644,7 +806,7 @@ AcpiTbParseRootTable ( * Complete the initialization of the root table array by examining * the header of each table */ - for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, NULL, i); diff --git a/sys/contrib/dev/acpica-unix/tables/tbxface.c b/sys/contrib/dev/acpica-unix/tables/tbxface.c index 4c12916c5a..507ea0bd68 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbxface.c +++ b/sys/contrib/dev/acpica-unix/tables/tbxface.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -150,7 +150,7 @@ AcpiAllocateRootTable ( UINT32 InitialTableCount) { - AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; return (AcpiTbResizeRootTableList ()); @@ -216,7 +216,7 @@ AcpiInitializeTables ( (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); AcpiGbl_RootTableList.Tables = InitialTableArray; - AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; if (AllowResize) { @@ -265,6 +265,7 @@ AcpiReallocateRootTable ( { ACPI_TABLE_DESC *Tables; ACPI_SIZE NewSize; + ACPI_SIZE CurrentSize; ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); @@ -279,9 +280,15 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (AE_SUPPORT); } - NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count + - ACPI_ROOT_TABLE_SIZE_INCREMENT) * - sizeof (ACPI_TABLE_DESC); + /* + * Get the current size of the root table and add the default + * increment to create the new table size. + */ + CurrentSize = (ACPI_SIZE) + AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC); + + NewSize = CurrentSize + + (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC)); /* Create new array and copy the old array */ @@ -291,10 +298,16 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize); - AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; + /* + * Update the root table descriptor. The new size will be the current + * number of tables plus the increment, independent of the reserved + * size of the original table list. + */ AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.MaxTableCount = + AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; @@ -341,7 +354,7 @@ AcpiGetTableHeader ( /* Walk the root table list */ - for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) @@ -426,7 +439,7 @@ AcpiGetTable ( /* Walk the root table list */ - for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) @@ -489,7 +502,7 @@ AcpiGetTableByIndex ( /* Validate index */ - if (TableIndex >= AcpiGbl_RootTableList.Count) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -534,6 +547,7 @@ AcpiTbLoadNamespace ( { ACPI_STATUS Status; UINT32 i; + ACPI_TABLE_HEADER *NewDsdt; ACPI_FUNCTION_TRACE (TbLoadNamespace); @@ -542,30 +556,50 @@ AcpiTbLoadNamespace ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); /* - * Load the namespace. The DSDT is required, but any SSDT and PSDT tables - * are optional. + * Load the namespace. The DSDT is required, but any SSDT and + * PSDT tables are optional. Verify the DSDT. */ - if (!AcpiGbl_RootTableList.Count || + if (!AcpiGbl_RootTableList.CurrentTableCount || !ACPI_COMPARE_NAME ( &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), ACPI_SIG_DSDT) || - ACPI_FAILURE (AcpiTbVerifyTable ( + ACPI_FAILURE (AcpiTbVerifyTable ( &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) { Status = AE_NO_ACPI_TABLES; goto UnlockAndExit; } - /* A valid DSDT is required */ + /* + * Save the DSDT pointer for simple access. This is the mapped memory + * address. We must take care here because the address of the .Tables + * array can change dynamically as tables are loaded at run-time. Note: + * .Pointer field is not validated until after call to AcpiTbVerifyTable. + */ + AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer; - Status = AcpiTbVerifyTable ( - &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); - if (ACPI_FAILURE (Status)) + /* + * Optionally copy the entire DSDT to local memory (instead of simply + * mapping it.) There are some BIOSs that corrupt or replace the original + * DSDT, creating the need for this option. Default is FALSE, do not copy + * the DSDT. + */ + if (AcpiGbl_CopyDsdtLocally) { - Status = AE_NO_ACPI_TABLES; - goto UnlockAndExit; + NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT); + if (NewDsdt) + { + AcpiGbl_DSDT = NewDsdt; + } } + /* + * Save the original DSDT header for detection of table corruption + * and/or replacement of the DSDT from outside the OS. + */ + ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT, + sizeof (ACPI_TABLE_HEADER)); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); /* Load and parse tables */ @@ -579,7 +613,7 @@ AcpiTbLoadNamespace ( /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), ACPI_SIG_SSDT) && diff --git a/sys/contrib/dev/acpica-unix/tables/tbxfroot.c b/sys/contrib/dev/acpica-unix/tables/tbxfroot.c index e0a571f36f..7319a18376 100644 --- a/sys/contrib/dev/acpica-unix/tables/tbxfroot.c +++ b/sys/contrib/dev/acpica-unix/tables/tbxfroot.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -227,7 +227,7 @@ AcpiFindRootPointer ( if (!TablePtr) { ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", + "Could not map memory at 0x%8.8X for length %u", ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); return_ACPI_STATUS (AE_NO_MEMORY); @@ -254,7 +254,7 @@ AcpiFindRootPointer ( if (!TablePtr) { ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", + "Could not map memory at 0x%8.8X for length %u", PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); return_ACPI_STATUS (AE_NO_MEMORY); @@ -284,7 +284,7 @@ AcpiFindRootPointer ( if (!TablePtr) { ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", + "Could not map memory at 0x%8.8X for length %u", ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); return_ACPI_STATUS (AE_NO_MEMORY); diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/Makefile b/sys/contrib/dev/acpica-unix/tools/acpiexec/Makefile index a8ec4d00f4..37c0358ee8 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/Makefile +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/Makefile @@ -1,146 +1,651 @@ -PROG= acpiexec -SRCS= aetables.c aehandlers.c aeexec.c aemain.c \ - ../../common/getopt.c \ - ../../debugger/dbcmds.c \ - ../../debugger/dbdisply.c \ - ../../debugger/dbexec.c \ - ../../debugger/dbfileio.c \ - ../../debugger/dbhistry.c \ - ../../debugger/dbinput.c \ - ../../debugger/dbstats.c \ - ../../debugger/dbutils.c \ - ../../debugger/dbxface.c \ - ../../disassembler/dmbuffer.c \ - ../../disassembler/dmnames.c \ - ../../disassembler/dmobject.c \ - ../../disassembler/dmopcode.c \ - ../../disassembler/dmresrc.c \ - ../../disassembler/dmresrcl.c \ - ../../disassembler/dmresrcs.c \ - ../../disassembler/dmutils.c \ - ../../disassembler/dmwalk.c \ - ../../events/evevent.c \ - ../../events/evgpeblk.c \ - ../../events/evgpe.c \ - ../../events/evmisc.c \ - ../../events/evregion.c \ - ../../events/evrgnini.c \ - ../../events/evsci.c \ - ../../events/evxface.c \ - ../../events/evxfevnt.c \ - ../../events/evxfregn.c \ - ../../hardware/hwacpi.c \ - ../../hardware/hwgpe.c \ - ../../hardware/hwregs.c \ - ../../hardware/hwsleep.c \ - ../../hardware/hwvalid.c \ - ../../hardware/hwxface.c \ - ../../dispatcher/dsfield.c \ - ../../dispatcher/dsinit.c \ - ../../dispatcher/dsmethod.c \ - ../../dispatcher/dsmthdat.c \ - ../../dispatcher/dsobject.c \ - ../../dispatcher/dsopcode.c \ - ../../dispatcher/dsutils.c \ - ../../dispatcher/dswexec.c \ - ../../dispatcher/dswload.c \ - ../../dispatcher/dswscope.c \ - ../../dispatcher/dswstate.c \ - ../../executer/exconfig.c \ - ../../executer/exconvrt.c \ - ../../executer/excreate.c \ - ../../executer/exdump.c \ - ../../executer/exfield.c \ - ../../executer/exfldio.c \ - ../../executer/exmisc.c \ - ../../executer/exmutex.c \ - ../../executer/exnames.c \ - ../../executer/exoparg1.c \ - ../../executer/exoparg2.c \ - ../../executer/exoparg3.c \ - ../../executer/exoparg6.c \ - ../../executer/exprep.c \ - ../../executer/exregion.c \ - ../../executer/exresnte.c \ - ../../executer/exresolv.c \ - ../../executer/exresop.c \ - ../../executer/exstore.c \ - ../../executer/exstoren.c \ - ../../executer/exstorob.c \ - ../../executer/exsystem.c \ - ../../executer/exutils.c \ - ../../parser/psargs.c \ - ../../parser/psloop.c \ - ../../parser/psopcode.c \ - ../../parser/psparse.c \ - ../../parser/psscope.c \ - ../../parser/pstree.c \ - ../../parser/psutils.c \ - ../../parser/pswalk.c \ - ../../parser/psxface.c \ - ../../namespace/nsaccess.c \ - ../../namespace/nsalloc.c \ - ../../namespace/nsdump.c \ - ../../namespace/nsdumpdv.c \ - ../../namespace/nseval.c \ - ../../namespace/nsinit.c \ - ../../namespace/nsload.c \ - ../../namespace/nsnames.c \ - ../../namespace/nsobject.c \ - ../../namespace/nsparse.c \ - ../../namespace/nspredef.c \ - ../../namespace/nssearch.c \ - ../../namespace/nsutils.c \ - ../../namespace/nswalk.c \ - ../../namespace/nsxfeval.c \ - ../../namespace/nsxfname.c \ - ../../namespace/nsxfobj.c \ - ../../resources/rsaddr.c \ - ../../resources/rscalc.c \ - ../../resources/rscreate.c \ - ../../resources/rsdump.c \ - ../../resources/rsio.c \ - ../../resources/rsinfo.c \ - ../../resources/rsirq.c \ - ../../resources/rslist.c \ - ../../resources/rsmemory.c \ - ../../resources/rsmisc.c \ - ../../resources/rsutils.c \ - ../../resources/rsxface.c \ - ../../tables/tbfadt.c \ - ../../tables/tbfind.c \ - ../../tables/tbinstal.c \ - ../../tables/tbutils.c \ - ../../tables/tbxface.c \ - ../../tables/tbxfroot.c \ - ../../utilities/utalloc.c \ - ../../utilities/utcache.c \ - ../../utilities/utcopy.c \ - ../../utilities/utdebug.c \ - ../../utilities/utdelete.c \ - ../../utilities/uteval.c \ - ../../utilities/utglobal.c \ - ../../utilities/utinit.c \ - ../../utilities/utlock.c \ - ../../utilities/utmath.c \ - ../../utilities/utmisc.c \ - ../../utilities/utmutex.c \ - ../../utilities/utobject.c \ - ../../utilities/utresrc.c \ - ../../utilities/utstate.c \ - ../../utilities/uttrack.c \ - ../../utilities/utxface.c \ - ../../osunixxf.c - - -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED -Wstrict-prototypes -I../../include - - -acpiexec : $(patsubst %.c,%.o, $(SRCS)) - $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -lrt -lpthread -o $(PROG) - -CLEANFILES= $(PROG) +# +# AcpiExec utility +# -clean : - rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) +PROG = acpiexec + +ACPICA_SRC = ../.. +ACPICA_COMMON = $(ACPICA_SRC)/common +ACPICA_CORE = $(ACPICA_SRC) +ACPICA_TOOLS = $(ACPICA_SRC)/tools +ACPICA_OSL = $(ACPICA_SRC)/os_specific/service_layers + +NOMAN= YES +CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -Wstrict-prototypes -I$(ACPICA_SRC)/include + +COMPILE = $(CC) -c $(CFLAGS) -o$@ $? +LDFLAGS += -lpthread -lrt + +OBJS = \ + aeexec.o \ + aehandlers.o \ + aemain.o \ + aetables.o \ + dbcmds.o \ + dbdisply.o \ + dbexec.o \ + dbfileio.o \ + dbhistry.o \ + dbinput.o \ + dbmethod.o \ + dbnames.o \ + dbstats.o \ + dbutils.o \ + dbxface.o \ + dmbuffer.o \ + dmnames.o \ + dmobject.o \ + dmopcode.o \ + dmresrc.o \ + dmresrcl.o \ + dmresrcs.o \ + dmutils.o \ + dmwalk.o \ + dsargs.o \ + dscontrol.o \ + dsfield.o \ + dsinit.o \ + dsmethod.o \ + dsmthdat.o \ + dsobject.o \ + dsopcode.o \ + dsutils.o \ + dswexec.o \ + dswload.o \ + dswload2.o \ + dswscope.o \ + dswstate.o \ + evevent.o \ + evgpe.o \ + evgpeblk.o \ + evgpeinit.o \ + evgpeutil.o \ + evmisc.o \ + evregion.o \ + evrgnini.o \ + evsci.o \ + evxface.o \ + evxfevnt.o \ + evxfgpe.o \ + evxfregn.o \ + exconfig.o \ + exconvrt.o \ + excreate.o \ + exdebug.o \ + exdump.o \ + exfield.o \ + exfldio.o \ + exmisc.o \ + exmutex.o \ + exnames.o \ + exoparg1.o \ + exoparg2.o \ + exoparg3.o \ + exoparg6.o \ + exprep.o \ + exregion.o \ + exresnte.o \ + exresolv.o \ + exresop.o \ + exstore.o \ + exstoren.o \ + exstorob.o \ + exsystem.o \ + exutils.o \ + getopt.o \ + hwacpi.o \ + hwgpe.o \ + hwpci.o \ + hwregs.o \ + hwsleep.o \ + hwvalid.o \ + hwxface.o \ + nsaccess.o \ + nsalloc.o \ + nsdump.o \ + nsdumpdv.o \ + nseval.o \ + nsinit.o \ + nsload.o \ + nsnames.o \ + nsobject.o \ + nsparse.o \ + nspredef.o \ + nsrepair.o \ + nsrepair2.o \ + nssearch.o \ + nsutils.o \ + nswalk.o \ + nsxfeval.o \ + nsxfname.o \ + nsxfobj.o \ + osunixxf.o \ + psargs.o \ + psloop.o \ + psopcode.o \ + psparse.o \ + psscope.o \ + pstree.o \ + psutils.o \ + pswalk.o \ + psxface.o \ + rsaddr.o \ + rscalc.o \ + rscreate.o \ + rsdump.o \ + rsinfo.o \ + rsio.o \ + rsirq.o \ + rslist.o \ + rsmemory.o \ + rsmisc.o \ + rsutils.o \ + rsxface.o \ + tbfadt.o \ + tbfind.o \ + tbinstal.o \ + tbutils.o \ + tbxface.o \ + tbxfroot.o \ + utalloc.o \ + utcache.o \ + utcopy.o \ + utdebug.o \ + utdecode.o \ + utdelete.o \ + uteval.o \ + utglobal.o \ + utids.o \ + utinit.o \ + utlock.o \ + utmath.o \ + utmisc.o \ + utmutex.o \ + utobject.o \ + utresrc.o \ + utstate.o \ + uttrack.o \ + utosi.o \ + utxferror.o \ + utxface.o + + +# +# Root rule +# +$(PROG) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -lpthread -o $(PROG) + $(COPYPROG) + + +# +# acpiexec source +# +aeexec.o : $(ACPICA_TOOLS)/acpiexec/aeexec.c + $(COMPILE) + +aehandlers.o : $(ACPICA_TOOLS)/acpiexec/aehandlers.c + $(COMPILE) + +aemain.o : $(ACPICA_TOOLS)/acpiexec/aemain.c + $(COMPILE) + +aetables.o : $(ACPICA_TOOLS)/acpiexec/aetables.c + $(COMPILE) + + +# +# ACPICA core source - common +# +getopt.o : $(ACPICA_COMMON)/getopt.c + $(COMPILE) + + +# +# ACPICA core source +# +dbcmds.o : $(ACPICA_CORE)/debugger/dbcmds.c + $(COMPILE) + +dbdisply.o : $(ACPICA_CORE)/debugger/dbdisply.c + $(COMPILE) + +dbexec.o : $(ACPICA_CORE)/debugger/dbexec.c + $(COMPILE) + +dbfileio.o : $(ACPICA_CORE)/debugger/dbfileio.c + $(COMPILE) + +dbhistry.o : $(ACPICA_CORE)/debugger/dbhistry.c + $(COMPILE) + +dbinput.o : $(ACPICA_CORE)/debugger/dbinput.c + $(COMPILE) + +dbmethod.o : $(ACPICA_CORE)/debugger/dbmethod.c + $(COMPILE) + +dbnames.o : $(ACPICA_CORE)/debugger/dbnames.c + $(COMPILE) + +dbstats.o : $(ACPICA_CORE)/debugger/dbstats.c + $(COMPILE) + +dbutils.o : $(ACPICA_CORE)/debugger/dbutils.c + $(COMPILE) + +dbxface.o : $(ACPICA_CORE)/debugger/dbxface.c + $(COMPILE) + +dmbuffer.o : $(ACPICA_CORE)/disassembler/dmbuffer.c + $(COMPILE) + +dmnames.o : $(ACPICA_CORE)/disassembler/dmnames.c + $(COMPILE) + +dmobject.o : $(ACPICA_CORE)/disassembler/dmobject.c + $(COMPILE) + +dmopcode.o : $(ACPICA_CORE)/disassembler/dmopcode.c + $(COMPILE) + +dmresrc.o : $(ACPICA_CORE)/disassembler/dmresrc.c + $(COMPILE) + +dmresrcl.o : $(ACPICA_CORE)/disassembler/dmresrcl.c + $(COMPILE) + +dmresrcs.o : $(ACPICA_CORE)/disassembler/dmresrcs.c + $(COMPILE) + +dmutils.o : $(ACPICA_CORE)/disassembler/dmutils.c + $(COMPILE) + +dmwalk.o : $(ACPICA_CORE)/disassembler/dmwalk.c + $(COMPILE) + +dsargs.o : $(ACPICA_CORE)/dispatcher/dsargs.c + $(COMPILE) + +dscontrol.o : $(ACPICA_CORE)/dispatcher/dscontrol.c + $(COMPILE) + +dsfield.o : $(ACPICA_CORE)/dispatcher/dsfield.c + $(COMPILE) + +dsinit.o : $(ACPICA_CORE)/dispatcher/dsinit.c + $(COMPILE) + +dsmethod.o : $(ACPICA_CORE)/dispatcher/dsmethod.c + $(COMPILE) + +dsmthdat.o : $(ACPICA_CORE)/dispatcher/dsmthdat.c + $(COMPILE) + +dsobject.o : $(ACPICA_CORE)/dispatcher/dsobject.c + $(COMPILE) + +dsopcode.o : $(ACPICA_CORE)/dispatcher/dsopcode.c + $(COMPILE) + +dsutils.o : $(ACPICA_CORE)/dispatcher/dsutils.c + $(COMPILE) + +dswexec.o : $(ACPICA_CORE)/dispatcher/dswexec.c + $(COMPILE) + +dswload.o : $(ACPICA_CORE)/dispatcher/dswload.c + $(COMPILE) + +dswload2.o : $(ACPICA_CORE)/dispatcher/dswload2.c + $(COMPILE) + +dswscope.o : $(ACPICA_CORE)/dispatcher/dswscope.c + $(COMPILE) + +dswstate.o : $(ACPICA_CORE)/dispatcher/dswstate.c + $(COMPILE) + +evevent.o : $(ACPICA_CORE)/events/evevent.c + $(COMPILE) + +evgpe.o : $(ACPICA_CORE)/events/evgpe.c + $(COMPILE) + +evgpeblk.o : $(ACPICA_CORE)/events/evgpeblk.c + $(COMPILE) + +evgpeinit.o : $(ACPICA_CORE)/events/evgpeinit.c + $(COMPILE) + +evgpeutil.o : $(ACPICA_CORE)/events/evgpeutil.c + $(COMPILE) + +evmisc.o : $(ACPICA_CORE)/events/evmisc.c + $(COMPILE) + +evregion.o : $(ACPICA_CORE)/events/evregion.c + $(COMPILE) + +evrgnini.o : $(ACPICA_CORE)/events/evrgnini.c + $(COMPILE) + +evsci.o : $(ACPICA_CORE)/events/evsci.c + $(COMPILE) + +evxface.o : $(ACPICA_CORE)/events/evxface.c + $(COMPILE) + +evxfevnt.o : $(ACPICA_CORE)/events/evxfevnt.c + $(COMPILE) + +evxfgpe.o : $(ACPICA_CORE)/events/evxfgpe.c + $(COMPILE) + +evxfregn.o : $(ACPICA_CORE)/events/evxfregn.c + $(COMPILE) + +exconfig.o : $(ACPICA_CORE)/executer/exconfig.c + $(COMPILE) + +exconvrt.o : $(ACPICA_CORE)/executer/exconvrt.c + $(COMPILE) + +excreate.o : $(ACPICA_CORE)/executer/excreate.c + $(COMPILE) + +exdebug.o : $(ACPICA_CORE)/executer/exdebug.c + $(COMPILE) + +exdump.o : $(ACPICA_CORE)/executer/exdump.c + $(COMPILE) + +exfield.o : $(ACPICA_CORE)/executer/exfield.c + $(COMPILE) + +exfldio.o : $(ACPICA_CORE)/executer/exfldio.c + $(COMPILE) + +exmisc.o : $(ACPICA_CORE)/executer/exmisc.c + $(COMPILE) + +exmutex.o : $(ACPICA_CORE)/executer/exmutex.c + $(COMPILE) + +exnames.o : $(ACPICA_CORE)/executer/exnames.c + $(COMPILE) + +exoparg1.o : $(ACPICA_CORE)/executer/exoparg1.c + $(COMPILE) + +exoparg2.o : $(ACPICA_CORE)/executer/exoparg2.c + $(COMPILE) + +exoparg3.o : $(ACPICA_CORE)/executer/exoparg3.c + $(COMPILE) + +exoparg6.o : $(ACPICA_CORE)/executer/exoparg6.c + $(COMPILE) + +exprep.o : $(ACPICA_CORE)/executer/exprep.c + $(COMPILE) + +exregion.o : $(ACPICA_CORE)/executer/exregion.c + $(COMPILE) + +exresnte.o : $(ACPICA_CORE)/executer/exresnte.c + $(COMPILE) + +exresolv.o : $(ACPICA_CORE)/executer/exresolv.c + $(COMPILE) + +exresop.o : $(ACPICA_CORE)/executer/exresop.c + $(COMPILE) + +exstore.o : $(ACPICA_CORE)/executer/exstore.c + $(COMPILE) +exstoren.o : $(ACPICA_CORE)/executer/exstoren.c + $(COMPILE) + +exstorob.o : $(ACPICA_CORE)/executer/exstorob.c + $(COMPILE) + +exsystem.o : $(ACPICA_CORE)/executer/exsystem.c + $(COMPILE) + +exutils.o : $(ACPICA_CORE)/executer/exutils.c + $(COMPILE) + +hwacpi.o : $(ACPICA_CORE)/hardware/hwacpi.c + $(COMPILE) + +hwgpe.o : $(ACPICA_CORE)/hardware/hwgpe.c + $(COMPILE) + +hwpci.o : $(ACPICA_CORE)/hardware/hwpci.c + $(COMPILE) + +hwregs.o : $(ACPICA_CORE)/hardware/hwregs.c + $(COMPILE) + +hwsleep.o : $(ACPICA_CORE)/hardware/hwsleep.c + $(COMPILE) + +hwvalid.o : $(ACPICA_CORE)/hardware/hwvalid.c + $(COMPILE) + +hwxface.o : $(ACPICA_CORE)/hardware/hwxface.c + $(COMPILE) + +nsaccess.o : $(ACPICA_CORE)/namespace/nsaccess.c + $(COMPILE) + +nsalloc.o : $(ACPICA_CORE)/namespace/nsalloc.c + $(COMPILE) + +nsdump.o : $(ACPICA_CORE)/namespace/nsdump.c + $(COMPILE) + +nsdumpdv.o : $(ACPICA_CORE)/namespace/nsdumpdv.c + $(COMPILE) + +nseval.o : $(ACPICA_CORE)/namespace/nseval.c + $(COMPILE) + +nsinit.o : $(ACPICA_CORE)/namespace/nsinit.c + $(COMPILE) + +nsload.o : $(ACPICA_CORE)/namespace/nsload.c + $(COMPILE) + +nsnames.o : $(ACPICA_CORE)/namespace/nsnames.c + $(COMPILE) + +nsobject.o : $(ACPICA_CORE)/namespace/nsobject.c + $(COMPILE) + +nsparse.o : $(ACPICA_CORE)/namespace/nsparse.c + $(COMPILE) + +nspredef.o : $(ACPICA_CORE)/namespace/nspredef.c + $(COMPILE) + +nsrepair.o : $(ACPICA_CORE)/namespace/nsrepair.c + $(COMPILE) + +nsrepair2.o : $(ACPICA_CORE)/namespace/nsrepair2.c + $(COMPILE) + +nssearch.o : $(ACPICA_CORE)/namespace/nssearch.c + $(COMPILE) + +nsutils.o : $(ACPICA_CORE)/namespace/nsutils.c + $(COMPILE) + +nswalk.o : $(ACPICA_CORE)/namespace/nswalk.c + $(COMPILE) + +nsxfeval.o : $(ACPICA_CORE)/namespace/nsxfeval.c + $(COMPILE) + +nsxfname.o : $(ACPICA_CORE)/namespace/nsxfname.c + $(COMPILE) + +nsxfobj.o : $(ACPICA_CORE)/namespace/nsxfobj.c + $(COMPILE) + +psargs.o : $(ACPICA_CORE)/parser/psargs.c + $(COMPILE) + +psloop.o : $(ACPICA_CORE)/parser/psloop.c + $(COMPILE) + +psopcode.o : $(ACPICA_CORE)/parser/psopcode.c + $(COMPILE) + +psparse.o : $(ACPICA_CORE)/parser/psparse.c + $(COMPILE) + +psscope.o : $(ACPICA_CORE)/parser/psscope.c + $(COMPILE) + +pstree.o : $(ACPICA_CORE)/parser/pstree.c + $(COMPILE) + +psutils.o : $(ACPICA_CORE)/parser/psutils.c + $(COMPILE) + +pswalk.o : $(ACPICA_CORE)/parser/pswalk.c + $(COMPILE) + +psxface.o : $(ACPICA_CORE)/parser/psxface.c + $(COMPILE) + +rsaddr.o : $(ACPICA_CORE)/resources/rsaddr.c + $(COMPILE) + +rscalc.o : $(ACPICA_CORE)/resources/rscalc.c + $(COMPILE) + +rscreate.o : $(ACPICA_CORE)/resources/rscreate.c + $(COMPILE) + +rsdump.o : $(ACPICA_CORE)/resources/rsdump.c + $(COMPILE) + +rsio.o : $(ACPICA_CORE)/resources/rsio.c + $(COMPILE) + +rsinfo.o : $(ACPICA_CORE)/resources/rsinfo.c + $(COMPILE) + +rsirq.o : $(ACPICA_CORE)/resources/rsirq.c + $(COMPILE) + +rslist.o : $(ACPICA_CORE)/resources/rslist.c + $(COMPILE) + +rsmemory.o : $(ACPICA_CORE)/resources/rsmemory.c + $(COMPILE) + +rsmisc.o : $(ACPICA_CORE)/resources/rsmisc.c + $(COMPILE) + +rsutils.o : $(ACPICA_CORE)/resources/rsutils.c + $(COMPILE) + +rsxface.o : $(ACPICA_CORE)/resources/rsxface.c + $(COMPILE) + +tbfadt.o : $(ACPICA_CORE)/tables/tbfadt.c + $(COMPILE) + +tbfind.o : $(ACPICA_CORE)/tables/tbfind.c + $(COMPILE) + +tbinstal.o : $(ACPICA_CORE)/tables/tbinstal.c + $(COMPILE) + +tbutils.o : $(ACPICA_CORE)/tables/tbutils.c + $(COMPILE) + +tbxface.o : $(ACPICA_CORE)/tables/tbxface.c + $(COMPILE) + +tbxfroot.o : $(ACPICA_CORE)/tables/tbxfroot.c + $(COMPILE) + +utalloc.o : $(ACPICA_CORE)/utilities/utalloc.c + $(COMPILE) + +utcache.o : $(ACPICA_CORE)/utilities/utcache.c + $(COMPILE) + +utcopy.o : $(ACPICA_CORE)/utilities/utcopy.c + $(COMPILE) + +utdebug.o : $(ACPICA_CORE)/utilities/utdebug.c + $(COMPILE) + +utdebug.o : $(ACPICA_CORE)/utilities/utdebug.c + $(COMPILE) + +utdelete.o : $(ACPICA_CORE)/utilities/utdelete.c + $(COMPILE) + +uteval.o : $(ACPICA_CORE)/utilities/uteval.c + $(COMPILE) + +utglobal.o : $(ACPICA_CORE)/utilities/utglobal.c + $(COMPILE) + +utids.o : $(ACPICA_CORE)/utilities/utids.c + $(COMPILE) + +utinit.o : $(ACPICA_CORE)/utilities/utinit.c + $(COMPILE) + +utlock.o : $(ACPICA_CORE)/utilities/utlock.c + $(COMPILE) + +utmath.o : $(ACPICA_CORE)/utilities/utmath.c + $(COMPILE) + +utmisc.o : $(ACPICA_CORE)/utilities/utmisc.c + $(COMPILE) + +utmutex.o : $(ACPICA_CORE)/utilities/utmutex.c + $(COMPILE) + +utobject.o : $(ACPICA_CORE)/utilities/utobject.c + $(COMPILE) + +utresrc.o : $(ACPICA_CORE)/utilities/utresrc.c + $(COMPILE) + +utstate.o : $(ACPICA_CORE)/utilities/utstate.c + $(COMPILE) + +uttrack.o : $(ACPICA_CORE)/utilities/uttrack.c + $(COMPILE) + +utosi.o : $(ACPICA_CORE)/utilities/utosi.c + $(COMPILE) + +utxferror.o : $(ACPICA_CORE)/utilities/utxferror.c + $(COMPILE) + +utxface.o : $(ACPICA_CORE)/utilities/utxface.c + $(COMPILE) + + +# +# Unix OS services layer (OSL) +# +osunixxf.o : $(ACPICA_OSL)/osunixxf.c + $(COMPILE) + + +clean : + rm -f $(PROG) $(PROG).exe $(OBJS) diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aecommon.h b/sys/contrib/dev/acpica-unix/tools/acpiexec/aecommon.h index 3febf6f40c..1352c6bc0d 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aecommon.h +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aecommon.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,11 +120,6 @@ #pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ #endif -#include -#include -#include -#include - #include "acpi.h" #include "accommon.h" #include "acparser.h" @@ -135,8 +130,34 @@ #include "acinterp.h" #include "acapps.h" -extern FILE *AcpiGbl_DebugFile; -extern BOOLEAN AcpiGbl_IgnoreErrors; +#include +#include +#include +#include + +extern FILE *AcpiGbl_DebugFile; +extern BOOLEAN AcpiGbl_IgnoreErrors; +extern UINT8 AcpiGbl_RegionFillValue; + +/* Check for unexpected exceptions */ + +#define AE_CHECK_STATUS(Name, Status, Expected) \ + if (Status != Expected) \ + { \ + AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \ + AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \ + } + +/* Check for unexpected non-AE_OK errors */ + +#define AE_CHECK_OK(Name, Status) AE_CHECK_STATUS (Name, Status, AE_OK); + +typedef struct ae_table_desc +{ + ACPI_TABLE_HEADER *Table; + struct ae_table_desc *Next; + +} AE_TABLE_DESC; /* * Debug Regions @@ -164,13 +185,14 @@ typedef struct ae_debug_regions #define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\ AcpiOsPrintf PARAM_LIST(fp);} -void __cdecl +void ACPI_SYSTEM_XFACE AeCtrlCHandler ( int Sig); ACPI_STATUS AeBuildLocalTables ( - ACPI_TABLE_HEADER *UserTable); + UINT32 TableCount, + AE_TABLE_DESC *TableList); ACPI_STATUS AeInstallTables ( @@ -210,7 +232,11 @@ AeDisplayAllMethods ( UINT32 DisplayCount); ACPI_STATUS -AeInstallHandlers ( +AeInstallEarlyHandlers ( + void); + +ACPI_STATUS +AeInstallLateHandlers ( void); void @@ -222,12 +248,21 @@ AeRegionHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext); UINT32 AeGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + void *Context); + +void +AeGlobalEventHandler ( + UINT32 Type, + ACPI_HANDLE GpeDevice, + UINT32 EventNumber, void *Context); #endif /* _AECOMMON */ diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aeexec.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/aeexec.c index 798e841689..671f51bd5d 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aeexec.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aeexec.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,38 +120,42 @@ /* Local prototypes */ -ACPI_STATUS +static ACPI_STATUS AeSetupConfiguration ( void *RegionAddr); -void +static void AfInstallGpeBlock ( void); -void +static void AeTestBufferArgument ( void); -void +static void AeTestPackageArgument ( void); -ACPI_STATUS +static ACPI_STATUS AeGetDevices ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue); -ACPI_STATUS +static ACPI_STATUS ExecuteOSI ( char *OsiString, UINT32 ExpectedResult); -void +static void AeHardwareInterfaces ( void); +static void +AeGenericRegisters ( + void); + extern unsigned char Ssdt3Code[]; @@ -168,11 +172,10 @@ extern unsigned char Ssdt3Code[]; * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AeSetupConfiguration ( void *RegionAddr) { - ACPI_STATUS Status; ACPI_OBJECT_LIST ArgList; ACPI_OBJECT Arg[3]; @@ -186,8 +189,7 @@ AeSetupConfiguration ( Arg[0].Type = ACPI_TYPE_INTEGER; Arg[0].Integer.Value = ACPI_TO_INTEGER (RegionAddr); - Status = AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL); - + (void) AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL); return (AE_OK); } @@ -200,11 +202,12 @@ AeSetupConfiguration ( * * RETURN: None * - * DESCRIPTION: Various GPE initialization + * DESCRIPTION: Test GPE block device initialization. Requires test ASL with + * A \GPE2 device. * *****************************************************************************/ -void +static void AfInstallGpeBlock ( void) { @@ -222,55 +225,54 @@ AfInstallGpeBlock ( return; } - BlockAddress.SpaceId = 0; + ACPI_MEMSET (&BlockAddress, 0, sizeof (ACPI_GENERIC_ADDRESS)); + BlockAddress.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY; BlockAddress.Address = 0x76540000; -#ifdef _OBSOLETE - Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 4, 8); -#endif - - /* Above should fail, ignore */ - Status = AcpiGetHandle (NULL, "\\GPE2", &Handle2); if (ACPI_SUCCESS (Status)) { - Status = AcpiInstallGpeBlock (Handle2, &BlockAddress, 8, 8); + Status = AcpiInstallGpeBlock (Handle2, &BlockAddress, 7, 8); + AE_CHECK_OK (AcpiInstallGpeBlock, Status); - AcpiInstallGpeHandler (Handle2, 8, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (Handle2, 8, ACPI_GPE_TYPE_WAKE); - AcpiEnableGpe (Handle2, 8, 0); + Status = AcpiInstallGpeHandler (Handle2, 8, + ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (Handle2, 8); + AE_CHECK_OK (AcpiEnableGpe, Status); Status = AcpiGetGpeDevice (0x30, &GpeDevice); + AE_CHECK_OK (AcpiGetGpeDevice, Status); + Status = AcpiGetGpeDevice (0x42, &GpeDevice); + AE_CHECK_OK (AcpiGetGpeDevice, Status); + Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice); - Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice); + AE_CHECK_OK (AcpiGetGpeDevice, Status); - AcpiRemoveGpeHandler (Handle2, 8, AeGpeHandler); + Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice); + AE_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST); - Status = AcpiRemoveGpeBlock (Handle2); + Status = AcpiRemoveGpeHandler (Handle2, 8, AeGpeHandler); + AE_CHECK_OK (AcpiRemoveGpeHandler, Status); } Status = AcpiGetHandle (NULL, "\\GPE3", &Handle3); if (ACPI_SUCCESS (Status)) { Status = AcpiInstallGpeBlock (Handle3, &BlockAddress, 8, 11); + AE_CHECK_OK (AcpiInstallGpeBlock, Status); } - -#ifdef _OBSOLETE - Status = AcpiRemoveGpeBlock (Handle); - Status = AcpiRemoveGpeBlock (Handle2); - Status = AcpiRemoveGpeBlock (Handle3); -#endif } /* Test using a Buffer object as a method argument */ -void +static void AeTestBufferArgument ( void) { - ACPI_STATUS Status; ACPI_OBJECT_LIST Params; ACPI_OBJECT BufArg; UINT8 Buffer[] = { @@ -286,26 +288,23 @@ AeTestBufferArgument ( Params.Count = 1; Params.Pointer = &BufArg; - - Status = AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL); + (void) AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL); } -ACPI_OBJECT PkgArg; -ACPI_OBJECT PkgElements[5]; -ACPI_OBJECT Pkg2Elements[5]; -ACPI_OBJECT_LIST Params; +static ACPI_OBJECT PkgArg; +static ACPI_OBJECT PkgElements[5]; +static ACPI_OBJECT Pkg2Elements[5]; +static ACPI_OBJECT_LIST Params; /* * Test using a Package object as an method argument */ -void +static void AeTestPackageArgument ( void) { - ACPI_STATUS Status; - /* Main package */ @@ -344,11 +343,11 @@ AeTestPackageArgument ( Params.Count = 1; Params.Pointer = &PkgArg; - Status = AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL); + (void) AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL); } -ACPI_STATUS +static ACPI_STATUS AeGetDevices ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -373,7 +372,7 @@ AeGetDevices ( * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS ExecuteOSI ( char *OsiString, UINT32 ExpectedResult) @@ -435,6 +434,47 @@ ExecuteOSI ( } +/****************************************************************************** + * + * FUNCTION: AeGenericRegisters + * + * DESCRIPTION: Call the AcpiRead/Write interfaces. + * + *****************************************************************************/ + +static ACPI_GENERIC_ADDRESS GenericRegister; + +static void +AeGenericRegisters ( + void) +{ + ACPI_STATUS Status; + UINT64 Value; + + + GenericRegister.Address = 0x1234; + GenericRegister.BitWidth = 64; + GenericRegister.BitOffset = 0; + GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; + + Status = AcpiRead (&Value, &GenericRegister); + AE_CHECK_OK (AcpiRead, Status); + + Status = AcpiWrite (Value, &GenericRegister); + AE_CHECK_OK (AcpiWrite, Status); + + GenericRegister.Address = 0x12345678; + GenericRegister.BitOffset = 0; + GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY; + + Status = AcpiRead (&Value, &GenericRegister); + AE_CHECK_OK (AcpiRead, Status); + + Status = AcpiWrite (Value, &GenericRegister); + AE_CHECK_OK (AcpiWrite, Status); +} + + /****************************************************************************** * * FUNCTION: AeHardwareInterfaces @@ -443,7 +483,7 @@ ExecuteOSI ( * *****************************************************************************/ -void +static void AeHardwareInterfaces ( void) { @@ -451,16 +491,30 @@ AeHardwareInterfaces ( UINT32 Value; - Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1); + AE_CHECK_OK (AcpiWriteBitRegister, Status); + Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1); + AE_CHECK_OK (AcpiWriteBitRegister, Status); + Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1); + AE_CHECK_OK (AcpiWriteBitRegister, Status); + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); + AE_CHECK_OK (AcpiWriteBitRegister, Status); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value); + AE_CHECK_OK (AcpiReadBitRegister, Status); + Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value); + AE_CHECK_OK (AcpiReadBitRegister, Status); + Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value); + AE_CHECK_OK (AcpiReadBitRegister, Status); + Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value); + AE_CHECK_OK (AcpiReadBitRegister, Status); } @@ -487,52 +541,139 @@ AeMiscellaneousTests ( AeHardwareInterfaces (); + AeGenericRegisters (); AeSetupConfiguration (Ssdt3Code); AeTestBufferArgument(); AeTestPackageArgument (); - ExecuteOSI ("Windows 2001", 0xFFFFFFFF); - ExecuteOSI ("MichiganTerminalSystem", 0); + + + Status = AcpiInstallInterface (""); + AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER); + + Status = AcpiInstallInterface ("TestString"); + AE_CHECK_OK (AcpiInstallInterface, Status); + + Status = AcpiInstallInterface ("TestString"); + AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS); + + Status = AcpiRemoveInterface ("Windows 2006"); + AE_CHECK_OK (AcpiRemoveInterface, Status); + + Status = AcpiRemoveInterface ("TestString"); + AE_CHECK_OK (AcpiRemoveInterface, Status); + + Status = AcpiRemoveInterface ("XXXXXX"); + AE_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST); + + Status = AcpiInstallInterface ("AnotherTestString"); + AE_CHECK_OK (AcpiInstallInterface, Status); + + + Status = ExecuteOSI ("Windows 2001", 0xFFFFFFFF); + AE_CHECK_OK (ExecuteOSI, Status); + + Status = ExecuteOSI ("MichiganTerminalSystem", 0); + AE_CHECK_OK (ExecuteOSI, Status); ReturnBuf.Length = 32; ReturnBuf.Pointer = Buffer; - AcpiGetName (AcpiGbl_RootNode, ACPI_FULL_PATHNAME, &ReturnBuf); - AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0); + Status = AcpiGetName (AcpiGbl_RootNode, ACPI_FULL_PATHNAME, &ReturnBuf); + AE_CHECK_OK (AcpiGetName, Status); + + Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0); + AE_CHECK_OK (AcpiEnableEvent, Status); + + Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL); + AE_CHECK_OK (AcpiInstallGlobalEventHandler, Status); + + /* + * GPEs: Handlers, enable/disable, etc. + */ + Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 0); + AE_CHECK_OK (AcpiEnableGpe, Status); + + Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler); + AE_CHECK_OK (AcpiRemoveGpeHandler, Status); + + Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 0); + AE_CHECK_OK (AcpiEnableGpe, Status); + + Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE); + AE_CHECK_OK (AcpiSetGpe, Status); + + Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE); + AE_CHECK_OK (AcpiSetGpe, Status); + + + Status = AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 1); + AE_CHECK_OK (AcpiEnableGpe, Status); + + + Status = AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 2); + AE_CHECK_OK (AcpiEnableGpe, Status); - AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 0, ACPI_GPE_TYPE_WAKE_RUN); - AcpiEnableGpe (NULL, 0, ACPI_NOT_ISR); - AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler); - AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 0, ACPI_GPE_TYPE_WAKE_RUN); - AcpiEnableGpe (NULL, 0, ACPI_NOT_ISR); + Status = AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); - AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 1, ACPI_GPE_TYPE_RUNTIME); - AcpiEnableGpe (NULL, 1, ACPI_NOT_ISR); + Status = AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); - AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 2, ACPI_GPE_TYPE_WAKE); - AcpiEnableGpe (NULL, 2, ACPI_NOT_ISR); + Status = AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); - AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 3, ACPI_GPE_TYPE_WAKE_RUN); + Status = AcpiGetHandle (NULL, "\\_SB", &Handle); + AE_CHECK_OK (AcpiGetHandle, Status); - AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 4, ACPI_GPE_TYPE_RUNTIME); + Status = AcpiSetupGpeForWake (Handle, NULL, 5); + AE_CHECK_OK (AcpiSetupGpeForWake, Status); - AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 5, ACPI_GPE_TYPE_WAKE); + Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE); + AE_CHECK_OK (AcpiGpeWakeup, Status); - AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); - AcpiSetGpeType (NULL, 0x19, ACPI_GPE_TYPE_WAKE_RUN); - AcpiEnableGpe (NULL, 0x19, ACPI_NOT_ISR); + Status = AcpiSetupGpeForWake (Handle, NULL, 6); + AE_CHECK_OK (AcpiSetupGpeForWake, Status); + + Status = AcpiSetupGpeForWake (Handle, NULL, 9); + AE_CHECK_OK (AcpiSetupGpeForWake, Status); + + Status = AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 0x19); + AE_CHECK_OK (AcpiEnableGpe, Status); + + + Status = AcpiInstallGpeHandler (NULL, 0x62, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); + AE_CHECK_OK (AcpiInstallGpeHandler, Status); + + Status = AcpiEnableGpe (NULL, 0x62); + AE_CHECK_OK (AcpiEnableGpe, Status); + + Status = AcpiDisableGpe (NULL, 0x62); + AE_CHECK_OK (AcpiDisableGpe, Status); AfInstallGpeBlock (); + /* Here is where the GPEs are actually "enabled" */ + + Status = AcpiUpdateAllGpes (); + AE_CHECK_OK (AcpiUpdateAllGpes, Status); Status = AcpiGetHandle (NULL, "RSRC", &Handle); if (ACPI_SUCCESS (Status)) @@ -549,41 +690,23 @@ AeMiscellaneousTests ( /* Test global lock */ Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get GlobalLock, %X\n", Status); - } + AE_CHECK_OK (AcpiAcquireGlobalLock, Status); Status = AcpiAcquireGlobalLock (0x5, &LockHandle2); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get GlobalLock, %X\n", Status); - } + AE_CHECK_OK (AcpiAcquireGlobalLock, Status); Status = AcpiReleaseGlobalLock (LockHandle1); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not release GlobalLock, %X\n", Status); - } + AE_CHECK_OK (AcpiReleaseGlobalLock, Status); Status = AcpiReleaseGlobalLock (LockHandle2); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not release GlobalLock, %X\n", Status); - } + AE_CHECK_OK (AcpiReleaseGlobalLock, Status); /* Get Devices */ Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not AcpiGetDevices, %X\n", Status); - } + AE_CHECK_OK (AcpiGetDevices, Status); Status = AcpiGetStatistics (&Stats); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not AcpiGetStatistics, %X\n", Status); - } + AE_CHECK_OK (AcpiGetStatistics, Status); } diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aehandlers.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/aehandlers.c index 47c95abae9..0ee6dd94be 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aehandlers.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aehandlers.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -120,19 +120,19 @@ /* Local prototypes */ -void +static void AeNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, void *Context); -void +static void AeDeviceNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, void *Context); -ACPI_STATUS +static ACPI_STATUS AeExceptionHandler ( ACPI_STATUS AmlStatus, ACPI_NAME Name, @@ -140,22 +140,62 @@ AeExceptionHandler ( UINT32 AmlOffset, void *Context); -ACPI_STATUS +static ACPI_STATUS AeTableHandler ( UINT32 Event, void *Table, void *Context); -ACPI_STATUS +static ACPI_STATUS AeRegionInit ( ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext); +static void +AeAttachedDataHandler ( + ACPI_HANDLE Object, + void *Data); + +static UINT32 +AeInterfaceHandler ( + ACPI_STRING InterfaceName, + UINT32 Supported); + +static UINT32 +AeEventHandler ( + void *Context); + +static UINT32 SigintCount = 0; +static AE_DEBUG_REGIONS AeRegions; + -UINT32 SigintCount = 0; -AE_DEBUG_REGIONS AeRegions; +/* + * We will override default region handlers for memory and I/O. Especially + * the SystemMemory handler, which must be implemented locally to simulate + * memory operation regions. Do not override the PCI_Config handler since + * we would like to exercise the default handler code. Do not override + * DataTable handler, since the default handler works correctly under + * acpiexec (and is used by the test suites.) + */ +static ACPI_ADR_SPACE_TYPE DefaultSpaceIdList[] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO +}; + +/* + * We will install handlers for some of the various address space IDs + */ +static ACPI_ADR_SPACE_TYPE SpaceIdList[] = +{ + ACPI_ADR_SPACE_EC, + ACPI_ADR_SPACE_SMBUS, + ACPI_ADR_SPACE_PCI_BAR_TARGET, + ACPI_ADR_SPACE_IPMI, + ACPI_ADR_SPACE_FIXED_HARDWARE +}; /****************************************************************************** @@ -170,7 +210,7 @@ AE_DEBUG_REGIONS AeRegions; * *****************************************************************************/ -void __cdecl +void ACPI_SYSTEM_XFACE AeCtrlCHandler ( int Sig) { @@ -178,7 +218,7 @@ AeCtrlCHandler ( signal (SIGINT, SIG_IGN); SigintCount++; - AcpiOsPrintf ("Caught a ctrl-c (#%d)\n\n", SigintCount); + AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount); if (AcpiGbl_MethodExecuting) { @@ -209,7 +249,7 @@ AeCtrlCHandler ( * *****************************************************************************/ -void +static void AeNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, @@ -259,7 +299,6 @@ AeNotifyHandler ( (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); break; } - } @@ -277,7 +316,7 @@ AeNotifyHandler ( * *****************************************************************************/ -void +static void AeDeviceNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, @@ -308,7 +347,7 @@ AeDeviceNotifyHandler ( * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AeExceptionHandler ( ACPI_STATUS AmlStatus, ACPI_NAME Name, @@ -352,7 +391,7 @@ AeExceptionHandler ( Arg[1].String.Length = ACPI_STRLEN (Exception); Arg[2].Type = ACPI_TYPE_INTEGER; - Arg[2].Integer.Value = ACPI_TO_INTEGER (AcpiOsGetThreadId()); + Arg[2].Integer.Value = AcpiOsGetThreadId(); /* Setup return buffer */ @@ -407,26 +446,31 @@ AeExceptionHandler ( * *****************************************************************************/ -char *TableEvents[] = +static char *TableEvents[] = { "LOAD", "UNLOAD", "UNKNOWN" }; -ACPI_STATUS +static ACPI_STATUS AeTableHandler ( UINT32 Event, void *Table, void *Context) { + ACPI_STATUS Status; + if (Event > ACPI_NUM_TABLE_EVENTS) { Event = ACPI_NUM_TABLE_EVENTS; } - /* TBD: could dump entire table header, need a header dump routine */ + /* Enable any GPEs associated with newly-loaded GPE methods */ + + Status = AcpiUpdateAllGpes (); + AE_CHECK_OK (AcpiUpdateAllGpes, Status); printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); @@ -438,17 +482,122 @@ AeTableHandler ( * * FUNCTION: AeGpeHandler * - * DESCRIPTION: GPE handler for acpiexec + * DESCRIPTION: Common GPE handler for acpiexec * *****************************************************************************/ UINT32 AeGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + void *Context) +{ + ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice; + + + AcpiOsPrintf ("[AcpiExec] GPE Handler received GPE%02X (GPE block %4.4s)\n", + GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT"); + + return (ACPI_REENABLE_GPE); +} + + +/****************************************************************************** + * + * FUNCTION: AeGlobalEventHandler + * + * DESCRIPTION: Global GPE/Fixed event handler + * + *****************************************************************************/ + +void +AeGlobalEventHandler ( + UINT32 Type, + ACPI_HANDLE Device, + UINT32 EventNumber, void *Context) { + char *TypeName; + + + switch (Type) + { + case ACPI_EVENT_TYPE_GPE: + TypeName = "GPE"; + break; + + case ACPI_EVENT_TYPE_FIXED: + TypeName = "FixedEvent"; + break; + + default: + TypeName = "UNKNOWN"; + break; + } + + AcpiOsPrintf ("[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", + TypeName, EventNumber, Device); +} + + +/****************************************************************************** + * + * FUNCTION: AeAttachedDataHandler + * + * DESCRIPTION: Handler for deletion of nodes with attached data (attached via + * AcpiAttachData) + * + *****************************************************************************/ + +static void +AeAttachedDataHandler ( + ACPI_HANDLE Object, + void *Data) +{ + ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); + + + AcpiOsPrintf ("Received an attached data deletion on %4.4s\n", + Node->Name.Ascii); +} + + +/****************************************************************************** + * + * FUNCTION: AeInterfaceHandler + * + * DESCRIPTION: Handler for _OSI invocations + * + *****************************************************************************/ + +static UINT32 +AeInterfaceHandler ( + ACPI_STRING InterfaceName, + UINT32 Supported) +{ + ACPI_FUNCTION_NAME (AeInterfaceHandler); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Received _OSI (\"%s\"), is %ssupported\n", + InterfaceName, Supported == 0 ? "not " : "")); + + return (Supported); +} + +/****************************************************************************** + * + * FUNCTION: AeEventHandler + * + * DESCRIPTION: Handler for Fixed Events + * + *****************************************************************************/ - AcpiOsPrintf ("Received a GPE at handler\n"); +static UINT32 +AeEventHandler ( + void *Context) +{ return (0); } @@ -465,7 +614,7 @@ AeGpeHandler ( * *****************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AeRegionInit ( ACPI_HANDLE RegionHandle, UINT32 Function, @@ -477,13 +626,13 @@ AeRegionInit ( */ *RegionContext = RegionHandle; - return AE_OK; + return (AE_OK); } /****************************************************************************** * - * FUNCTION: AeInstallHandlers + * FUNCTION: AeInstallLateHandlers * * PARAMETERS: None * @@ -493,11 +642,63 @@ AeRegionInit ( * *****************************************************************************/ -ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 5, 6, 0x80}; -#define AEXEC_NUM_REGIONS 8 +ACPI_STATUS +AeInstallLateHandlers ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + /* Install some fixed event handlers */ + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AeEventHandler, NULL); + AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_RTC, AeEventHandler, NULL); + AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); + + /* + * Install handlers for some of the "device driver" address spaces + * such as EC, SMBus, etc. + */ + for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++) + { + /* Install handler at the root object */ + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + SpaceIdList[i], AeRegionHandler, AeRegionInit, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not install an OpRegion handler for %s space(%u)", + AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i])); + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AeInstallEarlyHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install handlers for the AcpiExec utility. + * + * Notes: Don't install handler for PCI_Config, we want to use the + * default handler to exercise that code. + * + *****************************************************************************/ ACPI_STATUS -AeInstallHandlers (void) +AeInstallEarlyHandlers ( + void) { ACPI_STATUS Status; UINT32 i; @@ -507,6 +708,13 @@ AeInstallHandlers (void) ACPI_FUNCTION_ENTRY (); + Status = AcpiInstallInterfaceHandler (AeInterfaceHandler); + if (ACPI_FAILURE (Status)) + { + printf ("Could not install interface handler, %s\n", + AcpiFormatException (Status)); + } + Status = AcpiInstallTableHandler (AeTableHandler, NULL); if (ACPI_FAILURE (Status)) { @@ -560,8 +768,12 @@ AeInstallHandlers (void) Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler, NULL); + AE_CHECK_OK (AcpiInstallNotifyHandler, Status); + Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler); + AE_CHECK_OK (AcpiRemoveNotifyHandler, Status); + Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler, NULL); if (ACPI_FAILURE (Status)) @@ -569,29 +781,39 @@ AeInstallHandlers (void) printf ("Could not install a notify handler, %s\n", AcpiFormatException (Status)); } + + Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); + AE_CHECK_OK (AcpiAttachData, Status); + + Status = AcpiDetachData (Handle, AeAttachedDataHandler); + AE_CHECK_OK (AcpiDetachData, Status); + + Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); + AE_CHECK_OK (AcpiAttachData, Status); } else { printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); } - /* Set a handler for all supported operation regions */ - for (i = 0; i < AEXEC_NUM_REGIONS; i++) + /* + * Install handlers that will override the default handlers for some of + * the space IDs. + */ + for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++) { - Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode, - SpaceId[i], AeRegionHandler); + /* Install handler at the root object */ - /* Install handler at the root object. - * TBD: all default handlers should be installed here! - */ Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, - SpaceId[i], AeRegionHandler, AeRegionInit, NULL); + DefaultSpaceIdList[i], AeRegionHandler, + AeRegionInit, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Could not install an OpRegion handler for %s space(%d)", - AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i])); + "Could not install a default OpRegion handler for %s space(%u)", + AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]), + DefaultSpaceIdList[i])); return (Status); } } @@ -602,8 +824,7 @@ AeInstallHandlers (void) */ AeRegions.NumberOfRegions = 0; AeRegions.RegionList = NULL; - - return Status; + return (Status); } @@ -625,12 +846,13 @@ AeRegionHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - ACPI_INTEGER *Value, + UINT64 *Value, void *HandlerContext, void *RegionContext) { - ACPI_OPERAND_OBJECT *RegionObject = (ACPI_OPERAND_OBJECT*) RegionContext; + ACPI_OPERAND_OBJECT *RegionObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, RegionContext); + UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Value); ACPI_PHYSICAL_ADDRESS BaseAddress; ACPI_SIZE Length; BOOLEAN BufferExists; @@ -649,7 +871,7 @@ AeRegionHandler ( */ if (RegionObject->Region.Type != ACPI_TYPE_REGION) { - return AE_OK; + return (AE_OK); } /* @@ -681,8 +903,9 @@ AeRegionHandler ( AcpiUtGetRegionName (RegionObject->Region.SpaceId), (UINT32) Address)); - if (SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + switch (SpaceId) { + case ACPI_ADR_SPACE_SYSTEM_IO: /* * For I/O space, exercise the port validation */ @@ -690,10 +913,12 @@ AeRegionHandler ( { case ACPI_READ: Status = AcpiHwReadPort (Address, (UINT32 *) Value, BitWidth); + AE_CHECK_OK (AcpiHwReadPort, Status); break; case ACPI_WRITE: Status = AcpiHwWritePort (Address, (UINT32) *Value, BitWidth); + AE_CHECK_OK (AcpiHwWritePort, Status); break; default: @@ -707,10 +932,11 @@ AeRegionHandler ( } /* Now go ahead and simulate the hardware */ - } + break; + + + case ACPI_ADR_SPACE_SMBUS: - else if (SpaceId == ACPI_ADR_SPACE_SMBUS) - { Length = 0; switch (Function & ACPI_IO_MASK) @@ -769,13 +995,37 @@ AeRegionHandler ( for (i = 0; i < Length; i++) { - ((UINT8 *) Value)[i+2] = (UINT8) (0xA0 + i); + Buffer[i+2] = (UINT8) (0xA0 + i); } - ((UINT8 *) Value)[0] = 0x7A; - ((UINT8 *) Value)[1] = (UINT8) Length; + Buffer[0] = 0x7A; + Buffer[1] = (UINT8) Length; + return (AE_OK); + + + case ACPI_ADR_SPACE_IPMI: /* ACPI 4.0 */ - return AE_OK; + AcpiOsPrintf ("AcpiExec: Received IPMI request: " + "Address %X BaseAddress %X Length %X Width %X BufferLength %u\n", + (UINT32) Address, (UINT32) BaseAddress, + Length, BitWidth, Buffer[1]); + + /* + * Regardless of a READ or WRITE, this handler is passed a 66-byte + * buffer in which to return the IPMI status/length/data. + * + * Return some example data to show use of the bidirectional buffer + */ + Buffer[0] = 0; /* Status byte */ + Buffer[1] = 64; /* Return buffer data length */ + Buffer[2] = 0; /* Completion code */ + Buffer[3] = 0x34; /* Power measurement */ + Buffer[4] = 0x12; /* Power measurement */ + Buffer[65] = 0xEE; /* last buffer byte */ + return (AE_OK); + + default: + break; } /* @@ -812,17 +1062,20 @@ AeRegionHandler ( RegionElement = AcpiOsAllocate (sizeof (AE_REGION)); if (!RegionElement) { - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } RegionElement->Buffer = AcpiOsAllocate (Length); if (!RegionElement->Buffer) { AcpiOsFree (RegionElement); - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } - ACPI_MEMSET (RegionElement->Buffer, 0, Length); + /* Initialize the region with the default fill value */ + + ACPI_MEMSET (RegionElement->Buffer, AcpiGbl_RegionFillValue, Length); + RegionElement->Address = BaseAddress; RegionElement->Length = Length; RegionElement->SpaceId = SpaceId; @@ -860,23 +1113,23 @@ AeRegionHandler ( * NOTE: RegionElement->Length is in bytes, therefore it we compare against * ByteWidth (see above) */ - if (((ACPI_INTEGER) Address + ByteWidth) > - ((ACPI_INTEGER)(RegionElement->Address) + RegionElement->Length)) + if (((UINT64) Address + ByteWidth) > + ((UINT64)(RegionElement->Address) + RegionElement->Length)) { ACPI_WARNING ((AE_INFO, - "Request on [%4.4s] is beyond region limit Req-%X+%X, Base=%X, Len-%X", + "Request on [%4.4s] is beyond region limit Req-0x%X+0x%X, Base=0x%X, Len-0x%X", (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address, ByteWidth, (UINT32)(RegionElement->Address), RegionElement->Length)); - return AE_AML_REGION_LIMIT; + return (AE_AML_REGION_LIMIT); } /* * Get BufferValue to point to the "address" in the buffer */ BufferValue = ((UINT8 *) RegionElement->Buffer + - ((ACPI_INTEGER) Address - (ACPI_INTEGER) RegionElement->Address)); + ((UINT64) Address - (UINT64) RegionElement->Address)); DoFunction: @@ -900,10 +1153,10 @@ DoFunction: break; default: - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - return AE_OK; -} + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aemain.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/aemain.c index 3aec0740fe..400322d896 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aemain.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aemain.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -122,11 +122,21 @@ #define _COMPONENT PARSER ACPI_MODULE_NAME ("aemain") -UINT8 AcpiGbl_BatchMode = 0; -BOOLEAN AcpiGbl_IgnoreErrors = FALSE; -BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; -BOOLEAN AcpiGbl_DebugTimeout = FALSE; -char BatchBuffer[128]; + +UINT8 AcpiGbl_RegionFillValue = 0; +BOOLEAN AcpiGbl_IgnoreErrors = FALSE; +BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; +BOOLEAN AcpiGbl_DebugTimeout = FALSE; + +static UINT8 AcpiGbl_BatchMode = 0; +static char BatchBuffer[128]; +static AE_TABLE_DESC *AeTableListHead = NULL; + +#define ASL_MAX_FILES 256 +static char *FileList[ASL_MAX_FILES]; + + +#define AE_SUPPORTED_OPTIONS "?b:d:e:f:gm^ovx:" /****************************************************************************** @@ -144,22 +154,29 @@ char BatchBuffer[128]; static void usage (void) { - printf ("Usage: acpiexec [Options] [InputFile]\n\n"); + printf ("Usage: acpiexec [options] AMLfile1 AMLfile2 ...\n\n"); printf ("Where:\n"); printf (" -? Display this message\n"); - printf (" -a Do not abort methods on error\n"); printf (" -b Batch mode command execution\n"); - printf (" -e [Method] Batch mode method execution\n"); - printf (" -i Do not run STA/INI methods during init\n"); - printf (" -m Display final memory use statistics\n"); - printf (" -o Send output to this file\n"); - printf (" -r Disable OpRegion address simulation\n"); - printf (" -s Enable Interpreter Slack Mode\n"); - printf (" -t Enable Interpreter Serialized Mode\n"); - printf (" -v Verbose init output\n"); - printf (" -x Specify debug output level\n"); - printf (" -z Enable debug semaphore timeout\n"); + printf (" -m [Method] Batch mode method execution. Default=MAIN\n"); + printf ("\n"); + + printf (" -da Disable method abort on error\n"); + printf (" -di Disable execution of STA/INI methods during init\n"); + printf (" -do Disable Operation Region address simulation\n"); + printf (" -dt Disable allocation tracking (performance)\n"); + printf ("\n"); + + printf (" -ef Enable display of final memory statistics\n"); + printf (" -em Enable Interpreter Serialized Mode\n"); + printf (" -es Enable Interpreter Slack Mode\n"); + printf (" -et Enable debug semaphore timeout\n"); + printf ("\n"); + + printf (" -f Operation Region initialization fill value\n"); + printf (" -v Verbose initialization output\n"); + printf (" -x Debug output level\n"); } @@ -187,6 +204,7 @@ AcpiDbRunBatchMode ( char *Cmd = Ptr; UINT8 Run = 0; + AcpiGbl_MethodExecuting = FALSE; AcpiGbl_StepToNextCall = FALSE; @@ -218,6 +236,191 @@ AcpiDbRunBatchMode ( } +/******************************************************************************* + * + * FUNCTION: FlStrdup + * + * DESCRIPTION: Local strdup function + * + ******************************************************************************/ + +static char * +FlStrdup ( + char *String) +{ + char *NewString; + + + NewString = AcpiOsAllocate (strlen (String) + 1); + if (!NewString) + { + return (NULL); + } + + strcpy (NewString, String); + return (NewString); +} + + +/******************************************************************************* + * + * FUNCTION: FlSplitInputPathname + * + * PARAMETERS: InputFilename - The user-specified ASL source file to be + * compiled + * OutDirectoryPath - Where the directory path prefix is + * returned + * OutFilename - Where the filename part is returned + * + * RETURN: Status + * + * DESCRIPTION: Split the input path into a directory and filename part + * 1) Directory part used to open include files + * 2) Filename part used to generate output filenames + * + ******************************************************************************/ + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename) +{ + char *Substring; + char *DirectoryPath; + char *Filename; + + + *OutDirectoryPath = NULL; + *OutFilename = NULL; + + if (!InputPath) + { + return (AE_OK); + } + + /* Get the path to the input filename's directory */ + + DirectoryPath = FlStrdup (InputPath); + if (!DirectoryPath) + { + return (AE_NO_MEMORY); + } + + Substring = strrchr (DirectoryPath, '\\'); + if (!Substring) + { + Substring = strrchr (DirectoryPath, '/'); + if (!Substring) + { + Substring = strrchr (DirectoryPath, ':'); + } + } + + if (!Substring) + { + DirectoryPath[0] = 0; + Filename = FlStrdup (InputPath); + } + else + { + Filename = FlStrdup (Substring + 1); + *(Substring+1) = 0; + } + + if (!Filename) + { + return (AE_NO_MEMORY); + } + + *OutDirectoryPath = DirectoryPath; + *OutFilename = Filename; + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AsDoWildcard + * + * PARAMETERS: DirectoryPathname - Path to parent directory + * FileSpecifier - the wildcard specification (*.c, etc.) + * + * RETURN: Pointer to a list of filenames + * + * DESCRIPTION: Process files via wildcards. This function is for the Windows + * case only. + * + ******************************************************************************/ + +static char ** +AsDoWildcard ( + char *DirectoryPathname, + char *FileSpecifier) +{ +#ifdef WIN32 + void *DirInfo; + char *Filename; + int FileCount; + + + FileCount = 0; + + /* Open parent directory */ + + DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); + if (!DirInfo) + { + /* Either the directory or file does not exist */ + + printf ("File or directory %s%s does not exist\n", DirectoryPathname, FileSpecifier); + return (NULL); + } + + /* Process each file that matches the wildcard specification */ + + while ((Filename = AcpiOsGetNextFilename (DirInfo))) + { + /* Add the filename to the file list */ + + FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); + strcpy (FileList[FileCount], Filename); + FileCount++; + + if (FileCount >= ASL_MAX_FILES) + { + printf ("Max files reached\n"); + FileList[0] = NULL; + return (FileList); + } + } + + /* Cleanup */ + + AcpiOsCloseDirectory (DirInfo); + FileList[FileCount] = NULL; + return (FileList); + +#else + if (!FileSpecifier) + { + return (NULL); + } + + /* + * Linux/Unix cases - Wildcards are expanded by the shell automatically. + * Just return the filename in a null terminated list + */ + FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); + strcpy (FileList[0], FileSpecifier); + FileList[1] = NULL; + + return (FileList); +#endif +} + + /****************************************************************************** * * FUNCTION: main @@ -238,7 +441,13 @@ main ( int j; ACPI_STATUS Status; UINT32 InitFlags; - ACPI_TABLE_HEADER *Table; + ACPI_TABLE_HEADER *Table = NULL; + UINT32 TableCount; + AE_TABLE_DESC *TableDesc; + char **WildcardList; + char *Filename; + char *Directory; + char *FullPathname; #ifdef _DEBUG @@ -246,14 +455,12 @@ main ( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif - printf ("\nIntel ACPI Component Architecture\nAML Execution/Debug Utility"); - printf (" version %8.8X", ((UINT32) ACPI_CA_VERSION)); - printf (" [%s]\n\n", __DATE__); + printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); if (argc < 2) { usage (); - return 0; + return (0); } signal (SIGINT, AeCtrlCHandler); @@ -265,76 +472,106 @@ main ( /* Init ACPI and start debugger thread */ - AcpiInitializeSubsystem (); + Status = AcpiInitializeSubsystem (); + AE_CHECK_OK (AcpiInitializeSubsystem, Status); /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, "?ab:de^gimo:rstvx:z")) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch(j) { - case 'a': - AcpiGbl_IgnoreErrors = TRUE; - break; - case 'b': if (strlen (AcpiGbl_Optarg) > 127) { printf ("**** The length of command line (%u) exceeded maximum (127)\n", (UINT32) strlen (AcpiGbl_Optarg)); - return -1; + return (-1); } AcpiGbl_BatchMode = 1; strcpy (BatchBuffer, AcpiGbl_Optarg); break; case 'd': - AcpiGbl_DbOpt_disasm = TRUE; - AcpiGbl_DbOpt_stats = TRUE; + switch (AcpiGbl_Optarg[0]) + { + case 'a': + AcpiGbl_IgnoreErrors = TRUE; + break; + + case 'i': + AcpiGbl_DbOpt_ini_methods = FALSE; + break; + + case 'o': + AcpiGbl_DbOpt_NoRegionSupport = TRUE; + break; + + case 't': + #ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisableMemTracking = TRUE; + #endif + break; + + default: + printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); + return (-1); + } break; case 'e': - AcpiGbl_BatchMode = 2; switch (AcpiGbl_Optarg[0]) { - case '^': - strcpy (BatchBuffer, "MAIN"); + case 'f': + #ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = TRUE; + #endif break; - default: - strcpy (BatchBuffer, AcpiGbl_Optarg); + + case 'm': + AcpiGbl_AllMethodsSerialized = TRUE; + printf ("Enabling AML Interpreter serialized mode\n"); + break; + + case 's': + AcpiGbl_EnableInterpreterSlack = TRUE; + printf ("Enabling AML Interpreter slack mode\n"); break; + + case 't': + AcpiGbl_DebugTimeout = TRUE; + break; + + default: + printf ("Unknown option: -e%s\n", AcpiGbl_Optarg); + return (-1); } break; + case 'f': + AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); + break; + case 'g': AcpiGbl_DbOpt_tables = TRUE; AcpiGbl_DbFilename = NULL; break; - case 'i': - AcpiGbl_DbOpt_ini_methods = FALSE; - break; - case 'm': -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiGbl_DisplayFinalMemStats = TRUE; -#endif - break; - - case 'o': - printf ("O option is not implemented\n"); - break; - - case 'r': - AcpiGbl_DbOpt_NoRegionSupport = TRUE; - break; + AcpiGbl_BatchMode = 2; + switch (AcpiGbl_Optarg[0]) + { + case '^': + strcpy (BatchBuffer, "MAIN"); + break; - case 's': - AcpiGbl_EnableInterpreterSlack = TRUE; - printf ("Enabling AML Interpreter slack mode\n"); + default: + strcpy (BatchBuffer, AcpiGbl_Optarg); + break; + } break; - case 't': - AcpiGbl_AllMethodsSerialized = TRUE; - printf ("Enabling AML Interpreter serialized mode\n"); + case 'o': + AcpiGbl_DbOpt_disasm = TRUE; + AcpiGbl_DbOpt_stats = TRUE; break; case 'v': @@ -347,14 +584,11 @@ main ( printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel); break; - case 'z': - AcpiGbl_DebugTimeout = TRUE; - break; - case '?': + case 'h': default: usage(); - return -1; + return (-1); } @@ -364,21 +598,89 @@ main ( InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } - /* Standalone filename is the only argument */ + /* The remaining arguments are filenames for ACPI tables */ if (argv[AcpiGbl_Optind]) { AcpiGbl_DbOpt_tables = TRUE; - AcpiGbl_DbFilename = argv[AcpiGbl_Optind]; + TableCount = 0; + + /* Get each of the ACPI table files on the command line */ + + while (argv[AcpiGbl_Optind]) + { + /* Split incoming path into a directory/filename combo */ + + Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Expand wildcards (Windows only) */ + + WildcardList = AsDoWildcard (Directory, Filename); + if (!WildcardList) + { + return (-1); + } + + while (*WildcardList) + { + FullPathname = AcpiOsAllocate ( + strlen (Directory) + strlen (*WildcardList) + 1); + + /* Construct a full path to the file */ + + strcpy (FullPathname, Directory); + strcat (FullPathname, *WildcardList); + + /* Get one table */ + + Status = AcpiDbReadTableFromFile (FullPathname, &Table); + if (ACPI_FAILURE (Status)) + { + printf ("**** Could not get input table %s, %s\n", FullPathname, + AcpiFormatException (Status)); + goto enterloop; + } + + AcpiOsFree (FullPathname); + AcpiOsFree (*WildcardList); + *WildcardList = NULL; + WildcardList++; + + /* + * Ignore an FACS or RSDT, we can't use them. + */ + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDT)) + { + AcpiOsFree (Table); + continue; + } + + /* Allocate and link a table descriptor */ + + TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC)); + TableDesc->Table = Table; + TableDesc->Next = AeTableListHead; + AeTableListHead = TableDesc; + + TableCount++; + } + + AcpiGbl_Optind++; + } - Status = AcpiDbReadTableFromFile (AcpiGbl_DbFilename, &Table); + /* Build a local RSDT with all tables and let ACPICA process the RSDT */ + + Status = AeBuildLocalTables (TableCount, AeTableListHead); if (ACPI_FAILURE (Status)) { - printf ("**** Could not get input table, %s\n", AcpiFormatException (Status)); - goto enterloop; + return (-1); } - AeBuildLocalTables (Table); Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { @@ -386,15 +688,18 @@ main ( goto enterloop; } - Status = AeInstallHandlers (); + /* + * Install most of the handlers. + * Override some default region handlers, especially SystemMemory + */ + Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { goto enterloop; } /* - * TBD: - * Need a way to call this after the "LOAD" command + * TBD: Need a way to call this after the "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) @@ -410,6 +715,11 @@ main ( goto enterloop; } + /* + * Install handlers for "device driver" space IDs (EC,SMBus, etc.) + * and fixed event handlers + */ + AeInstallLateHandlers (); AeMiscellaneousTests (); } @@ -430,6 +740,6 @@ enterloop: AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); } - return 0; + return (0); } diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c index 1bf3b1e0d2..0986a50864 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: aetables - Miscellaneous ACPI tables for acpiexec utility + * Module Name: aetables - ACPI table setup/install for acpiexec utility * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -114,6 +114,7 @@ *****************************************************************************/ #include "aecommon.h" +#include "aetables.h" #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("aetables") @@ -129,116 +130,35 @@ ACPI_PHYSICAL_ADDRESS AeLocalGetRootPointer ( void); -/* - * Misc ACPI tables to be installed - */ +/* User table (DSDT) */ -/* Default DSDT. This will be replaced with the input DSDT */ - -unsigned char DsdtCode[] = -{ - 0x44,0x53,0x44,0x54,0x24,0x00,0x00,0x00, /* 00000000 "DSDT$..." */ - 0x02,0x6F,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".oIntel." */ - 0x4E,0x75,0x6C,0x6C,0x44,0x53,0x44,0x54, /* 00000010 "NullDSDT" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x04,0x12,0x08,0x20, -}; - -/* Several example SSDTs */ - -unsigned char Ssdt1Code[] = /* Has method _T98 */ -{ - 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ - 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ - 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */ - 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */ -}; - -unsigned char Ssdt2Code[] = /* Has method _T99 */ -{ - 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ - 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ - 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */ - 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */ -}; - -unsigned char Ssdt3Code[] = /* Has method _T97 */ -{ - 0x54,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "TSDT0..." */ - 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ - 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */ - 0x39,0x37,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "97.p..`." */ -}; +static ACPI_TABLE_HEADER *DsdtToInstallOverride; -/* Example OEM table */ +/* Non-AML tables that are constructed locally and installed */ -unsigned char Oem1Code[] = -{ - 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */ - 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */ - 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */ - 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */ - 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */ -}; +static ACPI_TABLE_RSDP LocalRSDP; +static ACPI_TABLE_FACS LocalFACS; +static ACPI_TABLE_HEADER LocalTEST; +static ACPI_TABLE_HEADER LocalBADTABLE; /* - * Example installable control method - * - * DefinitionBlock ("", "DSDT", 2, "Intel", "MTHDTEST", 0x20090512) - * { - * Method (\_SI_._T97, 1, Serialized) - * { - * Store ("Example installed method", Debug) - * Store (Arg0, Debug) - * Return () - * } - * } - * - * Compiled byte code below. + * We need a local FADT so that the hardware subcomponent will function, + * even though the underlying OSD HW access functions don't do anything. */ -unsigned char MethodCode[] = -{ - 0x44,0x53,0x44,0x54,0x53,0x00,0x00,0x00, /* 00000000 "DSDTS..." */ - 0x02,0xF9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ - 0x4D,0x54,0x48,0x44,0x54,0x45,0x53,0x54, /* 00000010 "MTHDTEST" */ - 0x12,0x05,0x09,0x20,0x49,0x4E,0x54,0x4C, /* 00000018 "... INTL" */ - 0x22,0x04,0x09,0x20,0x14,0x2E,0x2E,0x5F, /* 00000020 "".. ..._" */ - 0x54,0x49,0x5F,0x5F,0x54,0x39,0x37,0x09, /* 00000028 "SI__T97." */ - 0x70,0x0D,0x45,0x78,0x61,0x6D,0x70,0x6C, /* 00000030 "p.Exampl" */ - 0x65,0x20,0x69,0x6E,0x73,0x74,0x61,0x6C, /* 00000038 "e instal" */ - 0x6C,0x65,0x64,0x20,0x6D,0x65,0x74,0x68, /* 00000040 "led meth" */ - 0x6F,0x64,0x00,0x5B,0x31,0x70,0x68,0x5B, /* 00000048 "od.[1ph[" */ - 0x31,0xA4,0x00, -}; - +static ACPI_TABLE_FADT LocalFADT; /* - * We need a local FADT so that the hardware subcomponent will function, - * even though the underlying OSD HW access functions don't do - * anything. + * Use XSDT so that both 32- and 64-bit versions of this utility will + * function automatically. */ -ACPI_TABLE_HEADER *DsdtToInstallOverride; -ACPI_TABLE_RSDP LocalRSDP; -ACPI_TABLE_FADT LocalFADT; -ACPI_TABLE_FACS LocalFACS; -ACPI_TABLE_HEADER LocalDSDT; -ACPI_TABLE_HEADER LocalTEST; -ACPI_TABLE_HEADER LocalBADTABLE; -ACPI_TABLE_RSDT *LocalRSDT; +static ACPI_TABLE_XSDT *LocalXSDT; -#define RSDT_TABLES 7 -#define RSDT_SIZE (sizeof (ACPI_TABLE_RSDT) + ((RSDT_TABLES -1) * sizeof (UINT32))) +#define BASE_XSDT_TABLES 7 +#define BASE_XSDT_SIZE (sizeof (ACPI_TABLE_XSDT) + \ + ((BASE_XSDT_TABLES -1) * sizeof (UINT64))) -#define ACPI_MAX_INIT_TABLES (16) -static ACPI_TABLE_DESC Tables[ACPI_MAX_INIT_TABLES]; +#define ACPI_MAX_INIT_TABLES (32) +static ACPI_TABLE_DESC Tables[ACPI_MAX_INIT_TABLES]; /****************************************************************************** @@ -276,161 +196,246 @@ AeTableOverride ( * * FUNCTION: AeBuildLocalTables * - * PARAMETERS: UserTable - pointer to an input table to be loaded. - * a DSDT or SSDT + * PARAMETERS: TableCount - Number of tables on the command line + * TableList - List of actual tables from files * * RETURN: Status * - * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, RSDT, + * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, XSDT, * FADT, and several other test tables. * *****************************************************************************/ ACPI_STATUS AeBuildLocalTables ( - ACPI_TABLE_HEADER *UserTable) + UINT32 TableCount, + AE_TABLE_DESC *TableList) { - ACPI_PHYSICAL_ADDRESS DsdtAddress; + ACPI_PHYSICAL_ADDRESS DsdtAddress = 0; + UINT32 XsdtSize; + AE_TABLE_DESC *NextTable; + UINT32 NextIndex; + ACPI_TABLE_FADT *ExternalFadt = NULL; - /* Build an RSDT */ + /* + * Update the table count. For DSDT, it is not put into the XSDT. For + * FADT, this is already accounted for since we usually install a + * local FADT. + */ + NextTable = TableList; + while (NextTable) + { + if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) + { + TableCount--; + } + NextTable = NextTable->Next; + } - LocalRSDT = AcpiOsAllocate (RSDT_SIZE); - if (!LocalRSDT) + XsdtSize = BASE_XSDT_SIZE + (TableCount * sizeof (UINT64)); + + /* Build an XSDT */ + + LocalXSDT = AcpiOsAllocate (XsdtSize); + if (!LocalXSDT) { - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } - ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE); - ACPI_STRNCPY (LocalRSDT->Header.Signature, ACPI_SIG_RSDT, 4); - LocalRSDT->Header.Length = RSDT_SIZE; + ACPI_MEMSET (LocalXSDT, 0, XsdtSize); + ACPI_STRNCPY (LocalXSDT->Header.Signature, ACPI_SIG_XSDT, 4); + LocalXSDT->Header.Length = XsdtSize; + LocalXSDT->Header.Revision = 1; - LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); - LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE); - LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT); - LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */ + LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); + LocalXSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE); + LocalXSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT); /* Install two SSDTs to test multiple table support */ - LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code); - LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code); + LocalXSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code); + LocalXSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code); /* Install the OEM1 table to test LoadTable */ - LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code); + LocalXSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Oem1Code); - /* Build an RSDP */ + /* Install the OEMx table to test LoadTable */ - ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP)); - ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8); - LocalRSDP.Revision = 1; - LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT); - LocalRSDP.Length = sizeof (ACPI_TABLE_RSDT); - ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6); + LocalXSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&OemxCode); /* - * Examine the incoming user table. At this point, it has been verified - * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently + * Install the user tables. The DSDT must be installed in the FADT. + * All other tables are installed directly into the XSDT. */ - if (ACPI_COMPARE_NAME (UserTable->Signature, ACPI_SIG_DSDT)) + NextIndex = BASE_XSDT_TABLES; + NextTable = TableList; + while (NextTable) { - /* The incoming user table is a DSDT */ - - DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode); - DsdtToInstallOverride = UserTable; + /* + * Incoming DSDT or FADT are special cases. All other tables are + * just immediately installed into the XSDT. + */ + if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT)) + { + if (DsdtAddress) + { + printf ("Already found a DSDT, only one allowed\n"); + return (AE_ALREADY_EXISTS); + } + + /* The incoming user table is a DSDT */ + + DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode); + DsdtToInstallOverride = NextTable->Table; + } + else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT)) + { + ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table); + LocalXSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (NextTable->Table); + } + else + { + /* Install the table in the XSDT */ + + LocalXSDT->TableOffsetEntry[NextIndex] = ACPI_PTR_TO_PHYSADDR (NextTable->Table); + NextIndex++; + } + + NextTable = NextTable->Next; } - else - { - /* Build a local DSDT because incoming table is an SSDT or PSDT */ - ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER)); - ACPI_STRNCPY (LocalDSDT.Signature, ACPI_SIG_DSDT, 4); - LocalDSDT.Revision = 1; - LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER); - LocalDSDT.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalDSDT, LocalDSDT.Length); + /* Build an RSDP */ + + ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP)); + ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8); + ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6); + LocalRSDP.Revision = 2; + LocalRSDP.XsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalXSDT); + LocalRSDP.Length = sizeof (ACPI_TABLE_XSDT); + + /* Set checksums for both XSDT and RSDP */ + + LocalXSDT->Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) LocalXSDT, LocalXSDT->Header.Length); + LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH); - /* Install incoming table (SSDT or PSDT) directly into the RSDT */ + if (!DsdtAddress) + { + /* Use the local DSDT because incoming table(s) are all SSDT(s) */ - LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable); - DsdtAddress = ACPI_PTR_TO_PHYSADDR (&LocalDSDT); - DsdtToInstallOverride = &LocalDSDT; + DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode); + DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode); } - /* Set checksums for both RSDT and RSDP */ + if (ExternalFadt) + { + /* + * Use the external FADT, but we must update the DSDT/FACS addresses + * as well as the checksum + */ + ExternalFadt->Dsdt = DsdtAddress; + ExternalFadt->Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); + + if (ExternalFadt->Header.Length > ACPI_PTR_DIFF (&ExternalFadt->XDsdt, ExternalFadt)) + { + ExternalFadt->XDsdt = DsdtAddress; + ExternalFadt->XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); + } + /* Complete the FADT with the checksum */ + + ExternalFadt->Header.Checksum = 0; + ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) ExternalFadt, ExternalFadt->Header.Length); + } + else + { + /* + * Build a local FADT so we can test the hardware/event init + */ + ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT)); + ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4); - LocalRSDT->Header.Checksum = (UINT8) -AcpiTbChecksum ((void *) LocalRSDT, LocalRSDT->Header.Length); - LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH); + /* Setup FADT header and DSDT/FACS addresses */ - /* - * Build a FADT so we can test the hardware/event init - */ - ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT)); - ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4); + LocalFADT.Dsdt = 0; + LocalFADT.Facs = 0; - /* Setup FADT header and DSDT/FACS addresses */ + LocalFADT.XDsdt = DsdtAddress; + LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); - LocalFADT.Dsdt = DsdtAddress; - LocalFADT.Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); + LocalFADT.Header.Revision = 3; + LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT); - LocalFADT.XDsdt = DsdtAddress; - LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); + /* Miscellaneous FADT fields */ - LocalFADT.Header.Revision = 3; - LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT); + LocalFADT.Gpe0BlockLength = 16; + LocalFADT.Gpe0Block = 0x00001234; - /* Miscellaneous FADT fields */ + LocalFADT.Gpe1BlockLength = 6; + LocalFADT.Gpe1Block = 0x00005678; + LocalFADT.Gpe1Base = 96; - LocalFADT.Gpe0BlockLength = 16; - LocalFADT.Gpe1BlockLength = 6; - LocalFADT.Gpe1Base = 96; + LocalFADT.Pm1EventLength = 4; + LocalFADT.Pm1aEventBlock = 0x00001aaa; + LocalFADT.Pm1bEventBlock = 0x00001bbb; - LocalFADT.Pm1EventLength = 4; - LocalFADT.Pm1ControlLength = 2; - LocalFADT.PmTimerLength = 4; + LocalFADT.Pm1ControlLength = 2; + LocalFADT.Pm1aControlBlock = 0xB0; - LocalFADT.Gpe0Block = 0x00001234; - LocalFADT.Gpe1Block = 0x00005678; + LocalFADT.PmTimerLength = 4; + LocalFADT.PmTimerBlock = 0xA0; - LocalFADT.Pm1aEventBlock = 0x00001aaa; - LocalFADT.Pm1bEventBlock = 0x00001bbb; - LocalFADT.PmTimerBlock = 0xA0; - LocalFADT.Pm1aControlBlock = 0xB0; + LocalFADT.Pm2ControlBlock = 0xC0; + LocalFADT.Pm2ControlLength = 1; - /* Setup one example X-64 field */ + /* Setup one example X-64 field */ - LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; - LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock; - LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength); + LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; + LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock; + LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength); - /* Complete the FADT with the checksum */ + /* Complete the FADT with the checksum */ - LocalFADT.Header.Checksum = 0; - LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalFADT, LocalFADT.Header.Length); + LocalFADT.Header.Checksum = 0; + LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) &LocalFADT, LocalFADT.Header.Length); + } /* Build a FACS */ ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS)); ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4); + LocalFACS.Length = sizeof (ACPI_TABLE_FACS); LocalFACS.GlobalLock = 0x11AA0011; - /* Build a fake table [TEST] so that we make sure that the CA core ignores it */ - + /* + * Build a fake table [TEST] so that we make sure that the + * ACPICA core ignores it + */ ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER)); ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4); LocalTEST.Revision = 1; LocalTEST.Length = sizeof (ACPI_TABLE_HEADER); - LocalTEST.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalTEST, LocalTEST.Length); - - /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */ + LocalTEST.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) &LocalTEST, LocalTEST.Length); + /* + * Build a fake table with a bad signature [BAD!] so that we make + * sure that the ACPICA core ignores it + */ ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER)); ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4); LocalBADTABLE.Revision = 1; LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER); - LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalBADTABLE, LocalBADTABLE.Length); + LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) &LocalBADTABLE, LocalBADTABLE.Length); return (AE_OK); } @@ -454,9 +459,15 @@ AeInstallTables ( { ACPI_STATUS Status; + Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE); + AE_CHECK_OK (AcpiInitializeTables, Status); + Status = AcpiReallocateRootTable (); + AE_CHECK_OK (AcpiReallocateRootTable, Status); + Status = AcpiLoadTables (); + AE_CHECK_OK (AcpiLoadTables, Status); /* * Test run-time control method installation. Do it twice to test code @@ -501,5 +512,3 @@ AeLocalGetRootPointer ( return ((ACPI_PHYSICAL_ADDRESS) &LocalRSDP); } - - diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.h similarity index 52% copy from sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c copy to sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.h index 1bf3b1e0d2..20b724270d 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/aetables.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: aetables - Miscellaneous ACPI tables for acpiexec utility + * Module Name: aetables.h - Precompiled AML ACPI tables for acpiexec * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,29 +113,17 @@ * *****************************************************************************/ -#include "aecommon.h" +#ifndef __AETABLES_H__ +#define __AETABLES_H__ -#define _COMPONENT ACPI_TOOLS - ACPI_MODULE_NAME ("aetables") - -/* Local prototypes */ - -void -AeTableOverride ( - ACPI_TABLE_HEADER *ExistingTable, - ACPI_TABLE_HEADER **NewTable); - -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); /* - * Misc ACPI tables to be installed + * Miscellaneous pre-compiled AML ACPI tables to be installed */ /* Default DSDT. This will be replaced with the input DSDT */ -unsigned char DsdtCode[] = +static unsigned char DsdtCode[] = { 0x44,0x53,0x44,0x54,0x24,0x00,0x00,0x00, /* 00000000 "DSDT$..." */ 0x02,0x6F,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".oIntel." */ @@ -144,9 +132,18 @@ unsigned char DsdtCode[] = 0x04,0x12,0x08,0x20, }; +static unsigned char LocalDsdtCode[] = +{ + 0x44,0x53,0x44,0x54,0x24,0x00,0x00,0x00, /* 00000000 "DSDT$..." */ + 0x02,0x2C,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".,Intel." */ + 0x4C,0x6F,0x63,0x61,0x6C,0x00,0x00,0x00, /* 00000010 "Local..." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x30,0x07,0x09,0x20, +}; + /* Several example SSDTs */ -unsigned char Ssdt1Code[] = /* Has method _T98 */ +static unsigned char Ssdt1Code[] = /* Has method _T98 */ { 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ @@ -156,7 +153,7 @@ unsigned char Ssdt1Code[] = /* Has method _T98 */ 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */ }; -unsigned char Ssdt2Code[] = /* Has method _T99 */ +static unsigned char Ssdt2Code[] = /* Has method _T99 */ { 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ @@ -166,7 +163,7 @@ unsigned char Ssdt2Code[] = /* Has method _T99 */ 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */ }; -unsigned char Ssdt3Code[] = /* Has method _T97 */ +unsigned char Ssdt3Code[] = /* Has method _T97 */ { 0x54,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "TSDT0..." */ 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ @@ -178,7 +175,7 @@ unsigned char Ssdt3Code[] = /* Has method _T97 */ /* Example OEM table */ -unsigned char Oem1Code[] = +static unsigned char Oem1Code[] = { 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */ 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */ @@ -189,6 +186,34 @@ unsigned char Oem1Code[] = 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */ }; +/* ASL source for this table is at the end of this file */ + +static unsigned char OemxCode[] = +{ + 0x4F,0x45,0x4D,0x58,0xB0,0x00,0x00,0x00, /* 00000000 "OEMX...." */ + 0x02,0x54,0x4D,0x79,0x4F,0x45,0x4D,0x00, /* 00000008 ".TMyOEM." */ + 0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x00, /* 00000010 "Test...." */ + 0x32,0x04,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "2...INTL" */ + 0x31,0x03,0x10,0x20,0x14,0x1D,0x5F,0x49, /* 00000020 "1.. .._I" */ + 0x4E,0x49,0x00,0x70,0x0D,0x54,0x61,0x62, /* 00000028 "NI.p.Tab" */ + 0x6C,0x65,0x20,0x4F,0x45,0x4D,0x58,0x20, /* 00000030 "le OEMX " */ + 0x72,0x75,0x6E,0x6E,0x69,0x6E,0x67,0x00, /* 00000038 "running." */ + 0x5B,0x31,0x10,0x22,0x5C,0x5F,0x47,0x50, /* 00000040 "[1."\_GP" */ + 0x45,0x14,0x06,0x5F,0x45,0x30,0x37,0x00, /* 00000048 "E.._E07." */ + 0x14,0x06,0x5F,0x45,0x32,0x32,0x00,0x14, /* 00000050 ".._E22.." */ + 0x06,0x5F,0x4C,0x33,0x31,0x00,0x14,0x06, /* 00000058 "._L31..." */ + 0x5F,0x4C,0x36,0x36,0x00,0x5B,0x82,0x10, /* 00000060 "_L66.[.." */ + 0x4F,0x45,0x4D,0x31,0x08,0x5F,0x50,0x52, /* 00000068 "OEM1._PR" */ + 0x57,0x12,0x05,0x02,0x0A,0x07,0x00,0x5B, /* 00000070 "W......[" */ + 0x82,0x10,0x4F,0x45,0x4D,0x32,0x08,0x5F, /* 00000078 "..OEM2._" */ + 0x50,0x52,0x57,0x12,0x05,0x02,0x0A,0x66, /* 00000080 "PRW....f" */ + 0x00,0x10,0x26,0x5C,0x47,0x50,0x45,0x32, /* 00000088 "..&\GPE2" */ + 0x14,0x06,0x5F,0x4C,0x30,0x31,0x00,0x14, /* 00000090 ".._L01.." */ + 0x06,0x5F,0x45,0x30,0x37,0x00,0x08,0x5F, /* 00000098 "._E07.._" */ + 0x50,0x52,0x57,0x12,0x0C,0x02,0x12,0x08, /* 000000A0 "PRW....." */ + 0x02,0x5C,0x47,0x50,0x45,0x32,0x01,0x00 /* 000000A8 ".\GPE2.." */ +}; + /* * Example installable control method * @@ -204,7 +229,7 @@ unsigned char Oem1Code[] = * * Compiled byte code below. */ -unsigned char MethodCode[] = +static unsigned char MethodCode[] = { 0x44,0x53,0x44,0x54,0x53,0x00,0x00,0x00, /* 00000000 "DSDTS..." */ 0x02,0xF9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ @@ -220,286 +245,111 @@ unsigned char MethodCode[] = }; -/* - * We need a local FADT so that the hardware subcomponent will function, - * even though the underlying OSD HW access functions don't do - * anything. - */ -ACPI_TABLE_HEADER *DsdtToInstallOverride; -ACPI_TABLE_RSDP LocalRSDP; -ACPI_TABLE_FADT LocalFADT; -ACPI_TABLE_FACS LocalFACS; -ACPI_TABLE_HEADER LocalDSDT; -ACPI_TABLE_HEADER LocalTEST; -ACPI_TABLE_HEADER LocalBADTABLE; -ACPI_TABLE_RSDT *LocalRSDT; - -#define RSDT_TABLES 7 -#define RSDT_SIZE (sizeof (ACPI_TABLE_RSDT) + ((RSDT_TABLES -1) * sizeof (UINT32))) - -#define ACPI_MAX_INIT_TABLES (16) -static ACPI_TABLE_DESC Tables[ACPI_MAX_INIT_TABLES]; - - +#if 0 /****************************************************************************** * - * FUNCTION: AeTableOverride - * - * DESCRIPTION: Local implementation of AcpiOsTableOverride. - * Exercise the override mechanism + * DESCRIPTION: ASL tables that are used in RSDT/XSDT, also used to test + * Load/LoadTable operators. * *****************************************************************************/ -void -AeTableOverride ( - ACPI_TABLE_HEADER *ExistingTable, - ACPI_TABLE_HEADER **NewTable) +DefinitionBlock ("", "OEMX", 2, "MyOEM", "Test", 0x00000432) { + External (GPE2, DeviceObj) - /* This code exercises the table override mechanism in the core */ - - if (ACPI_COMPARE_NAME (ExistingTable->Signature, ACPI_SIG_DSDT)) + Method (_INI) { - *NewTable = DsdtToInstallOverride; + Store ("Table OEMX running", Debug) } - /* This code tests override of dynamically loaded tables */ - - else if (ACPI_COMPARE_NAME (ExistingTable->Signature, "TSDT")) + Scope (\_GPE) { - *NewTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Ssdt3Code); + Method (_E07) {} + Method (_E22) {} + Method (_L31) {} + Method (_L66) {} } -} - - -/****************************************************************************** - * - * FUNCTION: AeBuildLocalTables - * - * PARAMETERS: UserTable - pointer to an input table to be loaded. - * a DSDT or SSDT - * - * RETURN: Status - * - * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, RSDT, - * FADT, and several other test tables. - * - *****************************************************************************/ -ACPI_STATUS -AeBuildLocalTables ( - ACPI_TABLE_HEADER *UserTable) -{ - ACPI_PHYSICAL_ADDRESS DsdtAddress; - - - /* Build an RSDT */ - - LocalRSDT = AcpiOsAllocate (RSDT_SIZE); - if (!LocalRSDT) + Device (OEM1) { - return AE_NO_MEMORY; + Name (_PRW, Package(){7,0}) } - - ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE); - ACPI_STRNCPY (LocalRSDT->Header.Signature, ACPI_SIG_RSDT, 4); - LocalRSDT->Header.Length = RSDT_SIZE; - - LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); - LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE); - LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT); - LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */ - - /* Install two SSDTs to test multiple table support */ - - LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code); - LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code); - - /* Install the OEM1 table to test LoadTable */ - - LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code); - - /* Build an RSDP */ - - ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP)); - ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8); - LocalRSDP.Revision = 1; - LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT); - LocalRSDP.Length = sizeof (ACPI_TABLE_RSDT); - ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6); - - /* - * Examine the incoming user table. At this point, it has been verified - * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently - */ - if (ACPI_COMPARE_NAME (UserTable->Signature, ACPI_SIG_DSDT)) + Device (OEM2) { - /* The incoming user table is a DSDT */ - - DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode); - DsdtToInstallOverride = UserTable; + Name (_PRW, Package(){0x66,0}) } - else - { - /* Build a local DSDT because incoming table is an SSDT or PSDT */ - - ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER)); - ACPI_STRNCPY (LocalDSDT.Signature, ACPI_SIG_DSDT, 4); - LocalDSDT.Revision = 1; - LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER); - LocalDSDT.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalDSDT, LocalDSDT.Length); - /* Install incoming table (SSDT or PSDT) directly into the RSDT */ + Scope (\GPE2) + { + Method (_L01) {} + Method (_E07) {} - LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable); - DsdtAddress = ACPI_PTR_TO_PHYSADDR (&LocalDSDT); - DsdtToInstallOverride = &LocalDSDT; + Name (_PRW, Package() {Package() {\GPE2, 1}, 0}) } - - /* Set checksums for both RSDT and RSDP */ - - LocalRSDT->Header.Checksum = (UINT8) -AcpiTbChecksum ((void *) LocalRSDT, LocalRSDT->Header.Length); - LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH); - - /* - * Build a FADT so we can test the hardware/event init - */ - ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT)); - ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4); - - /* Setup FADT header and DSDT/FACS addresses */ - - LocalFADT.Dsdt = DsdtAddress; - LocalFADT.Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); - - LocalFADT.XDsdt = DsdtAddress; - LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS); - - LocalFADT.Header.Revision = 3; - LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT); - - /* Miscellaneous FADT fields */ - - LocalFADT.Gpe0BlockLength = 16; - LocalFADT.Gpe1BlockLength = 6; - LocalFADT.Gpe1Base = 96; - - LocalFADT.Pm1EventLength = 4; - LocalFADT.Pm1ControlLength = 2; - LocalFADT.PmTimerLength = 4; - - LocalFADT.Gpe0Block = 0x00001234; - LocalFADT.Gpe1Block = 0x00005678; - - LocalFADT.Pm1aEventBlock = 0x00001aaa; - LocalFADT.Pm1bEventBlock = 0x00001bbb; - LocalFADT.PmTimerBlock = 0xA0; - LocalFADT.Pm1aControlBlock = 0xB0; - - /* Setup one example X-64 field */ - - LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; - LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock; - LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength); - - /* Complete the FADT with the checksum */ - - LocalFADT.Header.Checksum = 0; - LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalFADT, LocalFADT.Header.Length); - - /* Build a FACS */ - - ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS)); - ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4); - LocalFACS.Length = sizeof (ACPI_TABLE_FACS); - LocalFACS.GlobalLock = 0x11AA0011; - - /* Build a fake table [TEST] so that we make sure that the CA core ignores it */ - - ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER)); - ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4); - - LocalTEST.Revision = 1; - LocalTEST.Length = sizeof (ACPI_TABLE_HEADER); - LocalTEST.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalTEST, LocalTEST.Length); - - /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */ - - ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER)); - ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4); - - LocalBADTABLE.Revision = 1; - LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER); - LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum ((void *) &LocalBADTABLE, LocalBADTABLE.Length); - - return (AE_OK); } +/* Parent gr.asl file */ -/****************************************************************************** - * - * FUNCTION: AeInstallTables - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Install the various ACPI tables - * - *****************************************************************************/ - -ACPI_STATUS -AeInstallTables ( - void) +DefinitionBlock ("", "DSDT", 2, "Intel", "Many", 0x00000001) { - ACPI_STATUS Status; - - Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE); - Status = AcpiReallocateRootTable (); - Status = AcpiLoadTables (); - - /* - * Test run-time control method installation. Do it twice to test code - * for an existing name. - */ - Status = AcpiInstallMethod (MethodCode); - if (ACPI_FAILURE (Status)) + Name (BUF1, Buffer() { - AcpiOsPrintf ("%s, Could not install method\n", - AcpiFormatException (Status)); + 0x4F,0x45,0x4D,0x58,0xB0,0x00,0x00,0x00, /* 00000000 "OEMX...." */ + 0x02,0x54,0x4D,0x79,0x4F,0x45,0x4D,0x00, /* 00000008 ".TMyOEM." */ + 0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x00, /* 00000010 "Test...." */ + 0x32,0x04,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "2...INTL" */ + 0x31,0x03,0x10,0x20,0x14,0x1D,0x5F,0x49, /* 00000020 "1.. .._I" */ + 0x4E,0x49,0x00,0x70,0x0D,0x54,0x61,0x62, /* 00000028 "NI.p.Tab" */ + 0x6C,0x65,0x20,0x4F,0x45,0x4D,0x58,0x20, /* 00000030 "le OEMX " */ + 0x72,0x75,0x6E,0x6E,0x69,0x6E,0x67,0x00, /* 00000038 "running." */ + 0x5B,0x31,0x10,0x22,0x5C,0x5F,0x47,0x50, /* 00000040 "[1."\_GP" */ + 0x45,0x14,0x06,0x5F,0x45,0x30,0x37,0x00, /* 00000048 "E.._E07." */ + 0x14,0x06,0x5F,0x45,0x32,0x32,0x00,0x14, /* 00000050 ".._E22.." */ + 0x06,0x5F,0x4C,0x33,0x31,0x00,0x14,0x06, /* 00000058 "._L31..." */ + 0x5F,0x4C,0x36,0x36,0x00,0x5B,0x82,0x10, /* 00000060 "_L66.[.." */ + 0x4F,0x45,0x4D,0x31,0x08,0x5F,0x50,0x52, /* 00000068 "OEM1._PR" */ + 0x57,0x12,0x05,0x02,0x0A,0x07,0x00,0x5B, /* 00000070 "W......[" */ + 0x82,0x10,0x4F,0x45,0x4D,0x32,0x08,0x5F, /* 00000078 "..OEM2._" */ + 0x50,0x52,0x57,0x12,0x05,0x02,0x0A,0x66, /* 00000080 "PRW....f" */ + 0x00,0x10,0x26,0x5C,0x47,0x50,0x45,0x32, /* 00000088 "..&\GPE2" */ + 0x14,0x06,0x5F,0x4C,0x30,0x31,0x00,0x14, /* 00000090 ".._L01.." */ + 0x06,0x5F,0x45,0x30,0x37,0x00,0x08,0x5F, /* 00000098 "._E07.._" */ + 0x50,0x52,0x57,0x12,0x0C,0x02,0x12,0x08, /* 000000A0 "PRW....." */ + 0x02,0x5C,0x47,0x50,0x45,0x32,0x01,0x00 /* 000000A8 ".\GPE2.." */ + }) + + Name (HNDL, 0) + Method (LD) + { + Load (BUF1, HNDL) + Store ("Load operator, handle:", Debug) + Store (HNDL, Debug) } - Status = AcpiInstallMethod (MethodCode); - if (ACPI_FAILURE (Status)) + Method (MAIN, 0, NotSerialized) { - AcpiOsPrintf ("%s, Could not install method\n", - AcpiFormatException (Status)); + Store ("Loading OEMX table", Debug) + Store (LoadTable ("OEMX", "MyOEM", "Test"), Debug) } - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AeLocalGetRootPointer - * - * PARAMETERS: Flags - not used - * Address - Where the root pointer is returned - * - * RETURN: Status - * - * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the - * standard ACPI mechanism. - * - *****************************************************************************/ + Scope (\_GPE) + { + Method (_L08) {} + Method (_E08) {} + Method (_L0B) {} + } -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) -{ + Device (DEV0) + { + Name (_PRW, Package() {0x11, 0}) + } - return ((ACPI_PHYSICAL_ADDRESS) &LocalRSDP); + Device (\GPE2) + { + Method (_L00) {} + } } +#endif +#endif /* __AETABLES_H__ */ diff --git a/sys/contrib/dev/acpica-unix/tools/acpiexec/osunixdir.c b/sys/contrib/dev/acpica-unix/tools/acpiexec/osunixdir.c index d9c55a1ef8..0ca569efda 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpiexec/osunixdir.c +++ b/sys/contrib/dev/acpica-unix/tools/acpiexec/osunixdir.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,9 @@ #include "acpisrc.h" +/* + * Allocated structure returned from OsOpenDirectory + */ typedef struct ExternalFindInfo { char *DirPathname; @@ -193,7 +196,7 @@ AcpiOsOpenDirectory ( * * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory * - * RETURN: Next filename matched. NULL if no more matches. + * RETURN: Next filename matched. NULL if no more matches. * * DESCRIPTION: Get the next file in the directory that matches the wildcard * specification. @@ -217,7 +220,9 @@ AcpiOsGetNextFilename ( if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0)) { if (dir_entry->d_name[0] == '.') + { continue; + } str_len = strlen (dir_entry->d_name) + strlen (ExternalInfo->DirPathname) + 2; @@ -226,7 +231,7 @@ AcpiOsGetNextFilename ( if (!temp_str) { printf ("Could not allocate buffer for temporary string\n"); - return NULL; + return (NULL); } strcpy (temp_str, ExternalInfo->DirPathname); @@ -238,7 +243,7 @@ AcpiOsGetNextFilename ( if (err == -1) { printf ("stat() error - should not happen\n"); - return NULL; + return (NULL); } if ((S_ISDIR (temp_stat.st_mode) @@ -255,7 +260,7 @@ AcpiOsGetNextFilename ( } } - return NULL; + return (NULL); } @@ -284,10 +289,22 @@ AcpiOsCloseDirectory ( free (DirHandle); } + /* Other functions acpisrc uses but that aren't standard on Unix */ -/* lowercase a string */ -char* +/******************************************************************************* + * + * FUNCTION: strlwr + * + * PARAMETERS: str - String to be lowercased. + * + * RETURN: str. + * + * DESCRIPTION: Lowercase a string in-place. + * + ******************************************************************************/ + +char * strlwr ( char *str) { @@ -295,11 +312,11 @@ strlwr ( int i; - length = strlen(str); + length = strlen (str); for (i = 0; i < length; i++) { - str[i] = tolower(str[i]); + str[i] = tolower ((int) str[i]); } return (str); diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/Makefile b/sys/contrib/dev/acpica-unix/tools/acpisrc/Makefile index 96816ce129..216c51a686 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/Makefile +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/Makefile @@ -8,7 +8,7 @@ CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../inclu aslmain : $(patsubst %.c,%.o, $(SRCS)) - $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) + $(CC) $(LDFLAGS) $(CFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) CLEANFILES= $(PROG) diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/acpisrc.h b/sys/contrib/dev/acpica-unix/tools/acpisrc/acpisrc.h index 651a0553f6..45545228e9 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/acpisrc.h +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/acpisrc.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -121,6 +121,9 @@ #define LINUX_HEADER_SIGNATURE " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS" #define LINES_IN_ASL_HEADER 29 /* Header as output from disassembler */ +#include "acpi.h" +#include "accommon.h" + #include #include #include @@ -132,9 +135,6 @@ #endif #include -#include "acpi.h" -#include "accommon.h" - /* Fixups for non-Win32 compilation */ #ifndef WIN32 @@ -278,6 +278,7 @@ extern ACPI_CONVERSION_TABLE LinuxConversionTable; extern ACPI_CONVERSION_TABLE CleanupConversionTable; extern ACPI_CONVERSION_TABLE StatsConversionTable; extern ACPI_CONVERSION_TABLE CustomConversionTable; +extern ACPI_CONVERSION_TABLE LicenseConversionTable; /* Prototypes */ diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/ascase.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/ascase.c index da1112d562..01b4e4f16d 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/ascase.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/ascase.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -197,7 +197,7 @@ AsLowerCaseString ( for (i = 0; i < TargetLength; i++) { - SubString1[i] = (char) tolower (SubString1[i]); + SubString1[i] = (char) tolower ((int) SubString1[i]); } SubBuffer = SubString1 + TargetLength; @@ -294,7 +294,7 @@ AsMixedCaseToUnderscores ( continue; } - if (islower (*SubBuffer)) + if (islower ((int) *SubBuffer)) { HasLowerCase = TRUE; } @@ -323,7 +323,7 @@ AsMixedCaseToUnderscores ( (SubBuffer[1] == 'X')) { SubBuffer += 2; - while (isxdigit (*SubBuffer)) + while (isxdigit ((int) *SubBuffer)) { SubBuffer++; } @@ -367,9 +367,9 @@ AsMixedCaseToUnderscores ( /* Check the rest of the identifier for any lower case letters */ SubString = SubBuffer; - while ((isalnum (*SubString)) || (*SubString == '_')) + while ((isalnum ((int) *SubString)) || (*SubString == '_')) { - if (islower (*SubString)) + if (islower ((int) *SubString)) { HasLowerCase = TRUE; } @@ -387,7 +387,7 @@ AsMixedCaseToUnderscores ( /* A capital letter may indicate the start of a token; save it */ - if (isupper (SubBuffer[0])) + if (isupper ((int) SubBuffer[0])) { TokenStart = SubBuffer; } @@ -399,15 +399,15 @@ AsMixedCaseToUnderscores ( * to * */ - else if ((islower (SubBuffer[0]) || isdigit (SubBuffer[0])) && - (isupper (SubBuffer[1]))) + else if ((islower ((int) SubBuffer[0]) || isdigit ((int) SubBuffer[0])) && + (isupper ((int) SubBuffer[1]))) { - if (isdigit (SubBuffer[0])) + if (isdigit ((int) SubBuffer[0])) { /* Ignore */ /* Ignore */ - if (isupper (*(SubBuffer-1)) || + if (isupper ((int) *(SubBuffer-1)) || *(SubBuffer-1) == '_') { SubBuffer++; @@ -420,7 +420,7 @@ AsMixedCaseToUnderscores ( * Find the end of this identifier (token) */ TokenEnd = SubBuffer; - while ((isalnum (*TokenEnd)) || (*TokenEnd == '_')) + while ((isalnum ((int) *TokenEnd)) || (*TokenEnd == '_')) { TokenEnd++; } @@ -428,7 +428,7 @@ AsMixedCaseToUnderscores ( /* Force the UpperCase letter (#2) to lower case */ Gbl_MadeChanges = TRUE; - SubBuffer[1] = (char) tolower (SubBuffer[1]); + SubBuffer[1] = (char) tolower ((int) SubBuffer[1]); SubString = TokenEnd; Length = 0; @@ -463,7 +463,7 @@ AsMixedCaseToUnderscores ( if (TokenStart) { - *TokenStart = (char) tolower (*TokenStart); + *TokenStart = (char) tolower ((int) *TokenStart); TokenStart = NULL; } } @@ -554,11 +554,11 @@ AsLowerCaseIdentifiers ( * Only lower case if we have an upper followed by a lower * This leaves the all-uppercase things (macros, etc.) intact */ - if ((isupper (SubBuffer[0])) && - (islower (SubBuffer[1]))) + if ((isupper ((int) SubBuffer[0])) && + (islower ((int) SubBuffer[1]))) { Gbl_MadeChanges = TRUE; - *SubBuffer = (char) tolower (*SubBuffer); + *SubBuffer = (char) tolower ((int) *SubBuffer); } SubBuffer++; @@ -595,15 +595,15 @@ AsUppercaseTokens ( if (SubBuffer) { TokenEnd = SubBuffer; - while ((isalnum (*TokenEnd)) || (*TokenEnd == '_')) + while ((isalnum ((int) *TokenEnd)) || (*TokenEnd == '_')) { TokenEnd++; } for (i = 0; i < (TokenEnd - SubBuffer); i++) { - if ((islower (SubBuffer[i])) && - (isupper (SubBuffer[i+1]))) + if ((islower ((int) SubBuffer[i])) && + (isupper ((int) SubBuffer[i+1]))) { SubString = TokenEnd; @@ -635,7 +635,7 @@ AsUppercaseTokens ( for (i = 0; i < (TokenEnd - SubBuffer); i++) { - SubBuffer[i] = (char) toupper (SubBuffer[i]); + SubBuffer[i] = (char) toupper ((int) SubBuffer[i]); } SubBuffer = TokenEnd; diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/asconvrt.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/asconvrt.c index b1c2ca4fe1..12b7102492 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/asconvrt.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/asconvrt.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -153,9 +153,9 @@ AsMatchExactWord ( NextChar = Word[WordLength]; PrevChar = * (Word -1); - if (isalnum (NextChar) || + if (isalnum ((int) NextChar) || (NextChar == '_') || - isalnum (PrevChar) || + isalnum ((int) PrevChar) || (PrevChar == '_')) { return (FALSE); @@ -298,7 +298,7 @@ AsCheckForBraces ( if (!Gbl_QuietMode) { - printf ("Missing braces for , line %d: %s\n", TotalLines, Filename); + printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); } } } @@ -317,7 +317,7 @@ AsCheckForBraces ( if (!Gbl_QuietMode) { - printf ("Missing braces for , line %d: %s\n", TotalLines, Filename); + printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); } } } @@ -336,7 +336,7 @@ AsCheckForBraces ( if (!Gbl_QuietMode) { - printf ("Missing braces for , line %d: %s\n", TotalLines, Filename); + printf ("Missing braces for , line %u: %s\n", TotalLines, Filename); } } } @@ -700,7 +700,7 @@ AsBracesOnSameLine ( * Check for digit will ignore initializer lists surrounded by braces. * This will work until we we need more complex detection. */ - if ((*SubBuffer == '{') && !isdigit (SubBuffer[1])) + if ((*SubBuffer == '{') && !isdigit ((int) SubBuffer[1])) { if (BlockBegin) { @@ -730,8 +730,10 @@ AsBracesOnSameLine ( * 1) There is a conditional compile on the line (starts with '#') * 2) Previous line ends with an '=' (Start of initializer block) * 3) Previous line ends with a comma (part of an init list) + * 4) Previous line ends with a backslash (part of a macro) */ if ((StartOfThisLine[1] != '#') && + (*Beginning != '\\') && (*Beginning != '/') && (*Beginning != '{') && (*Beginning != '=') && @@ -1124,7 +1126,7 @@ AsCountLines ( if (LongLineCount) { - VERBOSE_PRINT (("%d Lines longer than 80 found in %s\n", LongLineCount, Filename)); + VERBOSE_PRINT (("%u Lines longer than 80 found in %s\n", LongLineCount, Filename)); Gbl_LongLines += LongLineCount; } @@ -1291,7 +1293,7 @@ AsCountSourceLines ( Gbl_WhiteLines += WhiteCount; Gbl_CommentLines += CommentCount; - VERBOSE_PRINT (("%d Comment %d White %d Code %d Lines in %s\n", + VERBOSE_PRINT (("%u Comment %u White %u Code %u Lines in %s\n", CommentCount, WhiteCount, LineCount, LineCount+WhiteCount+CommentCount, Filename)); } diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/asfile.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/asfile.c index d656189809..6c0f5ae6a6 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/asfile.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/asfile.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -132,7 +132,7 @@ AsDetectLoneLineFeeds ( char *Filename, char *Buffer); -static inline int +static ACPI_INLINE int AsMaxInt (int a, int b) { return (a > b ? a : b); @@ -341,13 +341,13 @@ AsDetectLoneLineFeeds ( { if (!Gbl_IgnoreLoneLineFeeds) { - printf ("%s: ****File has UNIX format**** (LF only, not CR/LF) %d lines\n", + printf ("%s: ****File has UNIX format**** (LF only, not CR/LF) %u lines\n", Filename, LfCount); } } else { - printf ("%s: %d lone linefeeds in file\n", Filename, LfCount); + printf ("%s: %u lone linefeeds in file\n", Filename, LfCount); } return TRUE; } @@ -409,7 +409,8 @@ AsConvertFile ( Gbl_StructDefs = strstr (FileBuffer, "/* acpisrc:StructDefs"); Gbl_Files++; - VERBOSE_PRINT (("Processing %u bytes\n", strlen (FileBuffer))); + VERBOSE_PRINT (("Processing %u bytes\n", + (unsigned int) strlen (FileBuffer))); if (ConversionTable->LowerCaseTable) { @@ -795,7 +796,7 @@ AsGetFile ( Buffer = calloc (Size * 2, 1); if (!Buffer) { - printf ("Could not allocate buffer of size %d\n", Size * 2); + printf ("Could not allocate buffer of size %u\n", Size * 2); goto ErrorExit; } diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/asmain.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/asmain.c index c1fbb0cf13..ab64a1b5d7 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/asmain.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/asmain.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -191,8 +191,8 @@ AsStricmp ( do { - c1 = tolower (*String1); - c2 = tolower (*String2); + c1 = tolower ((int) *String1); + c2 = tolower ((int) *String2); String1++; String2++; @@ -340,6 +340,7 @@ AsDisplayUsage ( printf ("\n"); printf ("Usage: acpisrc [-c|l|u] [-dsvy] \n\n"); printf ("Where: -c Generate cleaned version of the source\n"); + printf (" -h Insert dual-license header into all modules\n"); printf (" -l Generate Linux version of the source\n"); printf (" -u Generate Custom source translation\n"); printf ("\n"); @@ -372,9 +373,7 @@ main ( UINT32 FileType; - printf ("ACPI Source Code Conversion Utility"); - printf (" version %8.8X", ((UINT32) ACPI_CA_VERSION)); - printf (" [%s]\n\n", __DATE__); + printf (ACPI_COMMON_SIGNON ("ACPI Source Code Conversion Utility")); if (argc < 2) { @@ -384,7 +383,7 @@ main ( /* Command line options */ - while ((j = AcpiGetopt (argc, argv, "cdlqsuvy")) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, "cdhlqsuvy")) != EOF) switch(j) { case 'l': /* Linux code generation */ @@ -402,6 +401,13 @@ main ( ConversionTable = &CleanupConversionTable; break; + case 'h': + /* Inject Dual-license header */ + + printf ("Inserting Dual-license header to all modules\n"); + ConversionTable = &LicenseConversionTable; + break; + case 's': /* Statistics only */ diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/asremove.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/asremove.c index 18f72f3c15..4db9decfe1 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/asremove.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/asremove.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/astable.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/astable.c index b813551469..00a7bc8789 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/astable.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/astable.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -161,9 +161,9 @@ ACPI_STRING_TABLE StandardDataTypes[] = { * ******************************************************************************/ -char LinuxHeader[] = +char DualLicenseHeader[] = "/*\n" -" * Copyright (C) 2000 - 2009, Intel Corp.\n" +" * Copyright (C) 2000 - 2011, Intel Corp.\n" " * All rights reserved.\n" " *\n" " * Redistribution and use in source and binary forms, with or without\n" @@ -208,40 +208,44 @@ ACPI_STRING_TABLE LinuxDataTypes[] = { /* Declarations first - ACPI types and standard C types */ - {"INT64 ", "s64 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"UINT64 ", "u64 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"UINT32 ", "u32 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"INT32 ", "s32 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"UINT16 ", "u16 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"INT16 ", "s16 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"UINT8 ", "u8 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"BOOLEAN ", "u8 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"char ", "char ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"void ", "void ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"char * ", "char * ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"void * ", "void * ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"int ", "int ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"FILE ", "FILE ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, - {"size_t ", "size_t ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"INT64 ", "s64 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"UINT64 ", "u64 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"UINT32 ", "u32 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"INT32 ", "s32 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"UINT16 ", "u16 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"INT16 ", "s16 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"UINT8 ", "u8 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"BOOLEAN ", "u8 ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"char ", "char ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"void ", "void ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"char * ", "char * ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"void * ", "void * ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"int ", "int ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"FILE ", "FILE ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, + {"size_t ", "size_t ", REPLACE_WHOLE_WORD | EXTRA_INDENT_C}, /* Now do embedded typecasts */ - {"UINT64", "u64", REPLACE_WHOLE_WORD}, - {"UINT32", "u32", REPLACE_WHOLE_WORD}, - {"UINT16", "u16", REPLACE_WHOLE_WORD}, - {"UINT8", "u8", REPLACE_WHOLE_WORD}, - {"BOOLEAN", "u8", REPLACE_WHOLE_WORD}, - - {"INT64 ", "s64 ", REPLACE_WHOLE_WORD}, - {"INT64", "s64", REPLACE_WHOLE_WORD}, - {"INT32 ", "s32 ", REPLACE_WHOLE_WORD}, - {"INT32", "s32", REPLACE_WHOLE_WORD}, - {"INT16 ", "s16 ", REPLACE_WHOLE_WORD}, - {"INT8 ", "s8 ", REPLACE_WHOLE_WORD}, - {"INT16", "s16", REPLACE_WHOLE_WORD}, - {"INT8", "s8", REPLACE_WHOLE_WORD}, - - {NULL, NULL, 0}, + {"UINT64", "u64", REPLACE_WHOLE_WORD}, + {"UINT32", "u32", REPLACE_WHOLE_WORD}, + {"UINT16", "u16", REPLACE_WHOLE_WORD}, + {"UINT8", "u8", REPLACE_WHOLE_WORD}, + {"BOOLEAN", "u8", REPLACE_WHOLE_WORD}, + + {"INT64 ", "s64 ", REPLACE_WHOLE_WORD}, + {"INT64", "s64", REPLACE_WHOLE_WORD}, + {"INT32 ", "s32 ", REPLACE_WHOLE_WORD}, + {"INT32", "s32", REPLACE_WHOLE_WORD}, + {"INT16 ", "s16 ", REPLACE_WHOLE_WORD}, + {"INT8 ", "s8 ", REPLACE_WHOLE_WORD}, + {"INT16", "s16", REPLACE_WHOLE_WORD}, + {"INT8", "s8", REPLACE_WHOLE_WORD}, + + /* Include file paths */ + + {"\"acpi.h\"", "", REPLACE_WHOLE_WORD}, + + {NULL, NULL, 0} }; ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { @@ -258,7 +262,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_COMMON_STATE", SRC_TYPE_STRUCT}, {"ACPI_COMMON_DESCRIPTOR", SRC_TYPE_STRUCT}, {"ACPI_COMPATIBLE_ID", SRC_TYPE_STRUCT}, - {"ACPI_COMPATIBLE_ID_LIST", SRC_TYPE_STRUCT}, {"ACPI_CONTROL_STATE", SRC_TYPE_STRUCT}, {"ACPI_CONVERSION_TABLE", SRC_TYPE_STRUCT}, {"ACPI_CPU_FLAGS", SRC_TYPE_SIMPLE}, @@ -269,6 +272,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_DEBUG_PRINT_INFO", SRC_TYPE_STRUCT}, {"ACPI_DESCRIPTOR", SRC_TYPE_UNION}, {"ACPI_DEVICE_ID", SRC_TYPE_STRUCT}, + {"ACPI_DEVICE_ID_LIST", SRC_TYPE_STRUCT}, {"ACPI_DEVICE_INFO", SRC_TYPE_STRUCT}, {"ACPI_DEVICE_WALK_INFO", SRC_TYPE_STRUCT}, {"ACPI_DMTABLE_DATA", SRC_TYPE_STRUCT}, @@ -281,7 +285,9 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_EXCEPTION_HANDLER", SRC_TYPE_SIMPLE}, {"ACPI_EXDUMP_INFO", SRC_TYPE_STRUCT}, {"ACPI_EXECUTE_TYPE", SRC_TYPE_SIMPLE}, + {"ACPI_EXECUTE_WALK", SRC_TYPE_STRUCT}, {"ACPI_EXTERNAL_LIST", SRC_TYPE_STRUCT}, + {"ACPI_EXTERNAL_FILE", SRC_TYPE_STRUCT}, {"ACPI_FADT_INFO", SRC_TYPE_STRUCT}, {"ACPI_FADT_PM_INFO", SRC_TYPE_STRUCT}, {"ACPI_FIELD_INFO", SRC_TYPE_STRUCT}, @@ -296,6 +302,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_GPE_DEVICE_INFO", SRC_TYPE_STRUCT}, {"ACPI_GPE_EVENT_INFO", SRC_TYPE_STRUCT}, {"ACPI_GPE_HANDLER", SRC_TYPE_SIMPLE}, + {"ACPI_GPE_HANDLER_INFO", SRC_TYPE_STRUCT}, {"ACPI_GPE_INDEX_INFO", SRC_TYPE_STRUCT}, {"ACPI_GPE_REGISTER_INFO", SRC_TYPE_STRUCT}, {"ACPI_GPE_WALK_INFO", SRC_TYPE_STRUCT}, @@ -309,7 +316,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_INTEGER_OVERLAY", SRC_TYPE_STRUCT}, {"ACPI_INTEGRITY_INFO", SRC_TYPE_STRUCT}, {"ACPI_INTERFACE_INFO", SRC_TYPE_STRUCT}, - {"ACPI_INTERNAL_RSDT", SRC_TYPE_STRUCT}, {"ACPI_INTERPRETER_MODE", SRC_TYPE_SIMPLE}, {"ACPI_IO_ADDRESS", SRC_TYPE_SIMPLE}, {"ACPI_IO_ATTRIBUTE", SRC_TYPE_STRUCT}, @@ -377,6 +383,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_PARSE_STATE", SRC_TYPE_STRUCT}, {"ACPI_PARSE_UPWARDS", SRC_TYPE_SIMPLE}, {"ACPI_PARSE_VALUE", SRC_TYPE_UNION}, + {"ACPI_PCI_DEVICE", SRC_TYPE_STRUCT}, {"ACPI_PCI_ID", SRC_TYPE_STRUCT}, {"ACPI_PCI_ROUTING_TABLE", SRC_TYPE_STRUCT}, {"ACPI_PHYSICAL_ADDRESS", SRC_TYPE_SIMPLE}, @@ -386,9 +393,12 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_POINTER", SRC_TYPE_STRUCT}, {"ACPI_POINTERS", SRC_TYPE_UNION}, {"ACPI_PORT_INFO", SRC_TYPE_STRUCT}, + {"ACPI_PREDEFINED_DATA", SRC_TYPE_STRUCT}, {"ACPI_PREDEFINED_INFO", SRC_TYPE_UNION}, {"ACPI_PREDEFINED_NAMES", SRC_TYPE_STRUCT}, {"ACPI_PSCOPE_STATE", SRC_TYPE_STRUCT}, + {"ACPI_REPAIR_FUNCTION", SRC_TYPE_SIMPLE}, + {"ACPI_REPAIR_INFO", SRC_TYPE_STRUCT}, {"ACPI_RESOURCE", SRC_TYPE_STRUCT}, {"ACPI_RESOURCE_ADDRESS", SRC_TYPE_STRUCT}, {"ACPI_RESOURCE_ADDRESS16", SRC_TYPE_STRUCT}, @@ -496,7 +506,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ASL_RESOURCE_NODE", SRC_TYPE_STRUCT}, {"ASL_WALK_CALLBACK", SRC_TYPE_SIMPLE}, {"COMMAND_INFO", SRC_TYPE_STRUCT}, - {"UINT32_STRUCT", SRC_TYPE_STRUCT}, {"UINT64_OVERLAY", SRC_TYPE_UNION}, {"UINT64_STRUCT", SRC_TYPE_STRUCT}, @@ -517,8 +526,11 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_TABLE_HEST", SRC_TYPE_STRUCT}, {"ACPI_TABLE_HPET", SRC_TYPE_STRUCT}, {"ACPI_TABLE_IBFT", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_IVRS", SRC_TYPE_STRUCT}, {"ACPI_TABLE_MADT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_MCFG", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_MCHI", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_MSCT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_RSDP", SRC_TYPE_STRUCT}, {"ACPI_TABLE_RSDT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_SBST", SRC_TYPE_STRUCT}, @@ -528,6 +540,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_TABLE_SRAT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_TCPA", SRC_TYPE_STRUCT}, {"ACPI_TABLE_UEFI", SRC_TYPE_STRUCT}, + {"ACPI_TABLE_WAET", SRC_TYPE_STRUCT}, {"ACPI_TABLE_WDAT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_WDRT", SRC_TYPE_STRUCT}, {"ACPI_TABLE_XSDT", SRC_TYPE_STRUCT}, @@ -544,64 +557,69 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_CPEP_POLLING", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HEADER", SRC_TYPE_STRUCT}, {"ACPI_DMAR_DEVICE_SCOPE", SRC_TYPE_STRUCT}, + {"ACPI_DMAR_ATSR", SRC_TYPE_STRUCT}, + {"ACPI_DMAR_RHSA", SRC_TYPE_STRUCT}, {"ACPI_DMAR_HARDWARE_UNIT", SRC_TYPE_STRUCT}, {"ACPI_DMAR_RESERVED_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_EINJ_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_EINJ_TRIGGER", SRC_TYPE_STRUCT}, {"ACPI_ERST_ENTRY", SRC_TYPE_STRUCT}, + {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, {"ACPI_HEST_AER_COMMON", SRC_TYPE_STRUCT}, {"ACPI_HEST_HEADER", SRC_TYPE_STRUCT}, {"ACPI_HEST_NOTIFY", SRC_TYPE_STRUCT}, + {"ACPI_HEST_IA_ERROR_BANK", SRC_TYPE_STRUCT}, + {"ACPI_HEST_IA_MACHINE_CHECK", SRC_TYPE_STRUCT}, + {"ACPI_HEST_IA_CORRECTED", SRC_TYPE_STRUCT}, + {"ACPI_HEST_IA_NMI", SRC_TYPE_STRUCT}, + {"ACPI_HEST_AER_ROOT", SRC_TYPE_STRUCT}, + {"ACPI_HEST_AER", SRC_TYPE_STRUCT}, + {"ACPI_HEST_AER_BRIDGE", SRC_TYPE_STRUCT}, + {"ACPI_HEST_GENERIC", SRC_TYPE_STRUCT}, + {"ACPI_HEST_GENERIC_STATUS", SRC_TYPE_STRUCT}, + {"ACPI_HEST_GENERIC_DATA", SRC_TYPE_STRUCT}, {"ACPI_IBFT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_IBFT_CONTROL", SRC_TYPE_STRUCT}, {"ACPI_IBFT_INITIATOR", SRC_TYPE_STRUCT}, {"ACPI_IBFT_NIC", SRC_TYPE_STRUCT}, {"ACPI_IBFT_TARGET", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_HEADER", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_HARDWARE", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_DE_HEADER", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_DEVICE4", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_DEVICE8A", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_DEVICE8B", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_DEVICE8C", SRC_TYPE_STRUCT}, + {"ACPI_IVRS_MEMORY", SRC_TYPE_STRUCT}, {"ACPI_MADT_ADDRESS_OVERRIDE", SRC_TYPE_STRUCT}, {"ACPI_MADT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_APIC", SRC_TYPE_STRUCT}, {"ACPI_MADT_IO_SAPIC", SRC_TYPE_STRUCT}, + {"ACPI_MADT_LOCAL_APIC", SRC_TYPE_STRUCT}, {"ACPI_MADT_LOCAL_APIC_NMI", SRC_TYPE_STRUCT}, + {"ACPI_MADT_LOCAL_APIC_OVERRIDE", SRC_TYPE_STRUCT}, {"ACPI_MADT_LOCAL_SAPIC", SRC_TYPE_STRUCT}, - {"ACPI_MADT_NMI_SOURCE", SRC_TYPE_STRUCT}, - {"ACPI_MADT_PROCESSOR_APIC", SRC_TYPE_STRUCT}, - {"ACPI_MADT_XRUPT_OVERRIDE", SRC_TYPE_STRUCT}, - {"ACPI_MADT_XRUPT_SOURCE", SRC_TYPE_STRUCT}, {"ACPI_MADT_LOCAL_X2APIC", SRC_TYPE_STRUCT}, {"ACPI_MADT_LOCAL_X2APIC_NMI", SRC_TYPE_STRUCT}, + {"ACPI_MADT_INTERRUPT_OVERRIDE", SRC_TYPE_STRUCT}, + {"ACPI_MADT_INTERRUPT_SOURCE", SRC_TYPE_STRUCT}, + {"ACPI_MADT_NMI_SOURCE", SRC_TYPE_STRUCT}, + {"ACPI_MADT_PROCESSOR_APIC", SRC_TYPE_STRUCT}, {"ACPI_MCFG_ALLOCATION", SRC_TYPE_STRUCT}, + {"ACPI_MSCT_PROXIMITY", SRC_TYPE_STRUCT}, + {"ACPI_RSDP_COMMON", SRC_TYPE_STRUCT}, + {"ACPI_RSDP_EXTENSION", SRC_TYPE_STRUCT}, {"ACPI_SRAT_CPU_AFFINITY", SRC_TYPE_STRUCT}, {"ACPI_SRAT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_SRAT_MEM_AFFINITY", SRC_TYPE_STRUCT}, {"ACPI_SRAT_X2APIC_CPU_AFFINITY", SRC_TYPE_STRUCT}, {"ACPI_WDAT_ENTRY", SRC_TYPE_STRUCT}, + /* Data Table compiler */ + + {"DT_FIELD", SRC_TYPE_STRUCT}, + {"DT_SUBTABLE", SRC_TYPE_STRUCT}, - /* Legacy names, should be removed */ - - {"EC_BOOT_RESOURCES", SRC_TYPE_STRUCT}, - {"HPET_TABLE", SRC_TYPE_STRUCT}, - {"MADT_ADDRESS_OVERRIDE", SRC_TYPE_STRUCT}, - {"MADT_INTERRUPT_OVERRIDE", SRC_TYPE_STRUCT}, - {"MADT_INTERRUPT_SOURCE", SRC_TYPE_STRUCT}, - {"MADT_IO_APIC", SRC_TYPE_STRUCT}, - {"MADT_IO_SAPIC", SRC_TYPE_STRUCT}, - {"MADT_LOCAL_APIC_NMI", SRC_TYPE_STRUCT}, - {"MADT_LOCAL_SAPIC", SRC_TYPE_STRUCT}, - {"MADT_NMI_SOURCE", SRC_TYPE_STRUCT}, - {"MADT_PROCESSOR_APIC", SRC_TYPE_STRUCT}, - {"MEMORY_AFFINITY", SRC_TYPE_STRUCT}, - {"MULTIPLE_APIC_TABLE", SRC_TYPE_STRUCT}, - {"SMART_BATTERY_TABLE", SRC_TYPE_STRUCT}, - {"STATIC_RESOURCE_ALLOC", SRC_TYPE_STRUCT}, - {"SYSTEM_RESOURCE_AFFINITY", SRC_TYPE_STRUCT}, - {"SYSTEM_LOCALITY_INFO", SRC_TYPE_STRUCT}, - {"FACS_DESCRIPTOR", SRC_TYPE_STRUCT}, - {"FADT_DESCRIPTOR_REV1", SRC_TYPE_STRUCT}, - {"FADT_DESCRIPTOR", SRC_TYPE_STRUCT}, - {"FADT_DESCRIPTOR_REV2_MINUS", SRC_TYPE_STRUCT}, - {"RSDP_DESCRIPTOR", SRC_TYPE_STRUCT}, - {"RSDT_DESCRIPTOR", SRC_TYPE_STRUCT}, - {"XSDT_DESCRIPTOR", SRC_TYPE_STRUCT}, {NULL, 0} }; @@ -646,7 +664,7 @@ ACPI_IDENTIFIER_TABLE LinuxConditionalIdentifiers[] = { ACPI_CONVERSION_TABLE LinuxConversionTable = { - LinuxHeader, + DualLicenseHeader, FLG_NO_CARRIAGE_RETURNS | FLG_LOWERCASE_DIRNAMES, AcpiIdentifiers, @@ -684,7 +702,6 @@ ACPI_CONVERSION_TABLE LinuxConversionTable = { * ******************************************************************************/ - ACPI_CONVERSION_TABLE CleanupConversionTable = { NULL, @@ -740,6 +757,40 @@ ACPI_CONVERSION_TABLE StatsConversionTable = { }; +/****************************************************************************** + * + * Dual License injection translation table + * + ******************************************************************************/ + +ACPI_CONVERSION_TABLE LicenseConversionTable = { + + DualLicenseHeader, + FLG_DEFAULT_FLAGS, + NULL, + + /* C source files */ + + NULL, + NULL, + NULL, + NULL, + NULL, + (CVT_COUNT_TABS | CVT_COUNT_NON_ANSI_COMMENTS | CVT_COUNT_LINES | + CVT_COUNT_SHORTMULTILINE_COMMENTS), + + /* C header files */ + + NULL, + NULL, + NULL, + NULL, + NULL, + (CVT_COUNT_TABS | CVT_COUNT_NON_ANSI_COMMENTS | CVT_COUNT_LINES | + CVT_COUNT_SHORTMULTILINE_COMMENTS), +}; + + /****************************************************************************** * * Customizable translation tables @@ -749,11 +800,15 @@ ACPI_CONVERSION_TABLE StatsConversionTable = { ACPI_STRING_TABLE CustomReplacements[] = { - {"(c) 1999 - 2009", "(c) 1999 - 2009", REPLACE_WHOLE_WORD}, + {"(c) 1999 - 2010", "(c) 1999 - 2011", REPLACE_WHOLE_WORD}, /* Main ACPICA source */ + {"(c) 2006 - 2010", "(c) 2006 - 2011", REPLACE_WHOLE_WORD}, /* Test suites */ #if 0 + {"(ACPI_INTEGER)", "(UINT64)", REPLACE_WHOLE_WORD}, + {"ACPI_INTEGER ", "UINT64 ", REPLACE_WHOLE_WORD}, + {"ACPI_INTEGER", "UINT64", REPLACE_WHOLE_WORD}, + {"ACPI_INTEGER_MAX", "ACPI_UINT64_MAX", REPLACE_WHOLE_WORD}, {"#include \"acpi.h\"", "#include \"acpi.h\"\n#include \"accommon.h\"", REPLACE_SUBSTRINGS}, - {"(c) 1999 - 2009", "(c) 1999 - 2009", REPLACE_WHOLE_WORD}, {"AcpiTbSumTable", "AcpiTbSumTable", REPLACE_WHOLE_WORD}, {"ACPI_SIG_BOOT", "ACPI_SIG_BOOT", REPLACE_WHOLE_WORD}, {"ACPI_SIG_DBGP", "ACPI_SIG_DBGP", REPLACE_WHOLE_WORD}, diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/asutils.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/asutils.c index 7b59178a5a..cbe8a8f716 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/asutils.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/asutils.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/tools/acpisrc/osunixdir.c b/sys/contrib/dev/acpica-unix/tools/acpisrc/osunixdir.c index d9c55a1ef8..0ca569efda 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpisrc/osunixdir.c +++ b/sys/contrib/dev/acpica-unix/tools/acpisrc/osunixdir.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,9 @@ #include "acpisrc.h" +/* + * Allocated structure returned from OsOpenDirectory + */ typedef struct ExternalFindInfo { char *DirPathname; @@ -193,7 +196,7 @@ AcpiOsOpenDirectory ( * * PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory * - * RETURN: Next filename matched. NULL if no more matches. + * RETURN: Next filename matched. NULL if no more matches. * * DESCRIPTION: Get the next file in the directory that matches the wildcard * specification. @@ -217,7 +220,9 @@ AcpiOsGetNextFilename ( if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0)) { if (dir_entry->d_name[0] == '.') + { continue; + } str_len = strlen (dir_entry->d_name) + strlen (ExternalInfo->DirPathname) + 2; @@ -226,7 +231,7 @@ AcpiOsGetNextFilename ( if (!temp_str) { printf ("Could not allocate buffer for temporary string\n"); - return NULL; + return (NULL); } strcpy (temp_str, ExternalInfo->DirPathname); @@ -238,7 +243,7 @@ AcpiOsGetNextFilename ( if (err == -1) { printf ("stat() error - should not happen\n"); - return NULL; + return (NULL); } if ((S_ISDIR (temp_stat.st_mode) @@ -255,7 +260,7 @@ AcpiOsGetNextFilename ( } } - return NULL; + return (NULL); } @@ -284,10 +289,22 @@ AcpiOsCloseDirectory ( free (DirHandle); } + /* Other functions acpisrc uses but that aren't standard on Unix */ -/* lowercase a string */ -char* +/******************************************************************************* + * + * FUNCTION: strlwr + * + * PARAMETERS: str - String to be lowercased. + * + * RETURN: str. + * + * DESCRIPTION: Lowercase a string in-place. + * + ******************************************************************************/ + +char * strlwr ( char *str) { @@ -295,11 +312,11 @@ strlwr ( int i; - length = strlen(str); + length = strlen (str); for (i = 0; i < length; i++) { - str[i] = tolower(str[i]); + str[i] = tolower ((int) str[i]); } return (str); diff --git a/sys/contrib/dev/acpica-unix/tools/acpixtract/Makefile b/sys/contrib/dev/acpica-unix/tools/acpixtract/Makefile index be7a735853..3dd15233f1 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpixtract/Makefile +++ b/sys/contrib/dev/acpica-unix/tools/acpixtract/Makefile @@ -7,7 +7,7 @@ CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../inclu acpixtract : $(patsubst %.c,%.o, $(SRCS)) - $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) + $(CC) $(LDFLAGS) $(CFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG) CLEANFILES= $(PROG) diff --git a/sys/contrib/dev/acpica-unix/tools/acpixtract/acpixtract.c b/sys/contrib/dev/acpica-unix/tools/acpixtract/acpixtract.c index 324db12c92..4604c09cc7 100644 --- a/sys/contrib/dev/acpica-unix/tools/acpixtract/acpixtract.c +++ b/sys/contrib/dev/acpica-unix/tools/acpixtract/acpixtract.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -119,61 +119,75 @@ #include #include -#define VERSION 0x20060324 +/* Note: This is a 32-bit program only */ + +#define VERSION 0x20100107 #define FIND_HEADER 0 #define EXTRACT_DATA 1 #define BUFFER_SIZE 256 -char Filename[16]; -unsigned char Data[16]; /* Local prototypes */ -void +static void CheckAscii ( - unsigned char *Name, + char *Name, int Count); -void +static void NormalizeSignature ( char *Signature); -unsigned int +static unsigned int GetNextInstance ( char *InputPathname, char *Signature); -int +static int ExtractTables ( char *InputPathname, char *Signature, unsigned int MinimumInstances); -size_t +static size_t GetTableHeader ( FILE *InputFile, unsigned char *OutputData); -unsigned int +static unsigned int CountTableInstances ( char *InputPathname, char *Signature); -int +static int ListTables ( char *InputPathname); -size_t +static size_t ConvertLine ( char *InputLine, unsigned char *OutputData); -void +static void DisplayUsage ( void); +typedef struct acpi_table_header +{ + char Signature[4]; + int Length; + unsigned char Revision; + unsigned char Checksum; + char OemId[6]; + char OemTableId[8]; + int OemRevision; + char AslCompilerId[4]; + int AslCompilerRevision; + +} ACPI_TABLE_HEADER; + struct TableInfo { unsigned int Signature; @@ -182,7 +196,9 @@ struct TableInfo struct TableInfo *Next; }; -struct TableInfo *ListHead = NULL; +static struct TableInfo *ListHead = NULL; +static char Filename[16]; +static unsigned char Data[16]; /****************************************************************************** @@ -193,7 +209,7 @@ struct TableInfo *ListHead = NULL; * ******************************************************************************/ -void +static void DisplayUsage ( void) { @@ -224,9 +240,9 @@ DisplayUsage ( * ******************************************************************************/ -void +static void CheckAscii ( - unsigned char *Name, + char *Name, int Count) { int i; @@ -234,7 +250,7 @@ CheckAscii ( for (i = 0; i < Count; i++) { - if (!Name[i] || !isprint (Name[i])) + if (!Name[i] || !isprint ((int) Name[i])) { Name[i] = ' '; } @@ -246,7 +262,7 @@ CheckAscii ( * * FUNCTION: NormalizeSignature * - * PARAMETERS: Name - Ascii string + * PARAMETERS: Name - Ascii string containing an ACPI signature * * RETURN: None * @@ -254,7 +270,7 @@ CheckAscii ( * ******************************************************************************/ -void +static void NormalizeSignature ( char *Signature) { @@ -270,11 +286,16 @@ NormalizeSignature ( * * FUNCTION: ConvertLine * + * PARAMETERS: InputLine - One line from the input acpidump file + * OutputData - Where the converted data is returned + * + * RETURN: The number of bytes actually converted + * * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes) * ******************************************************************************/ -size_t +static size_t ConvertLine ( char *InputLine, unsigned char *OutputData) @@ -290,7 +311,7 @@ ConvertLine ( End = strstr (InputLine + 2, " "); if (!End) { - return 0; /* Don't understand the format */ + return (0); /* Don't understand the format */ } *End = 0; @@ -323,11 +344,16 @@ ConvertLine ( * * FUNCTION: GetTableHeader * - * DESCRIPTION: Extract and convert a table heaader + * PARAMETERS: InputFile - Handle for the input acpidump file + * OutputData - Where the table header is returned + * + * RETURN: The actual number of bytes converted + * + * DESCRIPTION: Extract and convert an ACPI table header * ******************************************************************************/ -size_t +static size_t GetTableHeader ( FILE *InputFile, unsigned char *OutputData) @@ -344,7 +370,7 @@ GetTableHeader ( { if (!fgets (Buffer, BUFFER_SIZE, InputFile)) { - return TotalConverted; + return (TotalConverted); } BytesConverted = ConvertLine (Buffer, OutputData); @@ -353,11 +379,11 @@ GetTableHeader ( if (BytesConverted != 16) { - return TotalConverted; + return (TotalConverted); } } - return TotalConverted; + return (TotalConverted); } @@ -365,11 +391,17 @@ GetTableHeader ( * * FUNCTION: CountTableInstances * - * DESCRIPTION: Count the instances of table within the input file + * PARAMETERS: InputPathname - Filename for acpidump file + * Signature - Requested signature to count + * + * RETURN: The number of instances of the signature + * + * DESCRIPTION: Count the instances of tables with the given signature within + * the input acpidump file. * ******************************************************************************/ -unsigned int +static unsigned int CountTableInstances ( char *InputPathname, char *Signature) @@ -383,7 +415,7 @@ CountTableInstances ( if (!InputFile) { printf ("Could not open %s\n", InputPathname); - return 0; + return (0); } /* Count the number of instances of this signature */ @@ -406,7 +438,7 @@ CountTableInstances ( } fclose (InputFile); - return Instances; + return (Instances); } @@ -414,11 +446,20 @@ CountTableInstances ( * * FUNCTION: GetNextInstance * - * DESCRIPTION: + * PARAMETERS: InputPathname - Filename for acpidump file + * Signature - Requested ACPI signature + * + * RETURN: The next instance number for this signature. Zero if this + * is the first instance of this signature. + * + * DESCRIPTION: Get the next instance number of the specified table. If this + * is the first instance of the table, create a new instance + * block. Note: only SSDT and PSDT tables can have multiple + * instances. * ******************************************************************************/ -unsigned int +static unsigned int GetNextInstance ( char *InputPathname, char *Signature) @@ -439,12 +480,18 @@ GetNextInstance ( if (!Info) { + /* Signature not found, create new table info block */ + Info = malloc (sizeof (struct TableInfo)); + if (!Info) + { + printf ("Could not allocate memory\n"); + exit (0); + } Info->Signature = *(unsigned int *) Signature; Info->Instances = CountTableInstances (InputPathname, Signature); Info->NextInstance = 1; - Info->Next = ListHead; ListHead = Info; } @@ -462,11 +509,18 @@ GetNextInstance ( * * FUNCTION: ExtractTables * + * PARAMETERS: InputPathname - Filename for acpidump file + * Signature - Requested ACPI signature to extract. + * NULL means extract ALL tables. + * MinimumInstances - Min instances that are acceptable + * + * RETURN: Status + * * DESCRIPTION: Convert text ACPI tables to binary * ******************************************************************************/ -int +static int ExtractTables ( char *InputPathname, char *Signature, @@ -483,6 +537,7 @@ ExtractTables ( unsigned int Instances = 0; unsigned int ThisInstance; char ThisSignature[4]; + int Status = 0; /* Open input in text mode, output is in binary mode */ @@ -491,7 +546,7 @@ ExtractTables ( if (!InputFile) { printf ("Could not open %s\n", InputPathname); - return -1; + return (-1); } if (Signature) @@ -504,12 +559,13 @@ ExtractTables ( if (Instances < MinimumInstances) { printf ("Table %s was not found in %s\n", Signature, InputPathname); - return -1; + Status = -1; + goto CleanupAndExit; } if (Instances == 0) { - return 0; + goto CleanupAndExit; } } @@ -542,8 +598,10 @@ ExtractTables ( } } - /* Get the instance # for this signature */ - + /* + * Get the instance number for this signature. Only the + * SSDT and PSDT tables can have multiple instances. + */ ThisInstance = GetNextInstance (InputPathname, ThisSignature); /* Build an output filename and create/open the output file */ @@ -561,7 +619,8 @@ ExtractTables ( if (!OutputFile) { printf ("Could not open %s\n", Filename); - return -1; + Status = -1; + goto CleanupAndExit; } State = EXTRACT_DATA; @@ -580,8 +639,8 @@ ExtractTables ( OutputFile = NULL; State = FIND_HEADER; - printf ("Acpi table [%4.4s] - % 6d bytes written to %s\n", - ThisSignature, TotalBytesWritten, Filename); + printf ("Acpi table [%4.4s] - %u bytes written to %s\n", + ThisSignature, (unsigned int) TotalBytesWritten, Filename); continue; } @@ -596,14 +655,17 @@ ExtractTables ( { printf ("Write error on %s\n", Filename); fclose (OutputFile); - return -1; + OutputFile = NULL; + Status = -1; + goto CleanupAndExit; } TotalBytesWritten += BytesConverted; continue; default: - return -1; + Status = -1; + goto CleanupAndExit; } } @@ -612,6 +674,9 @@ ExtractTables ( printf ("Table %s was not found in %s\n", Signature, InputPathname); } + +CleanupAndExit: + if (OutputFile) { fclose (OutputFile); @@ -619,13 +684,13 @@ ExtractTables ( { /* Received an EOF while extracting data */ - printf ("Acpi table [%4.4s] - % 6d bytes written to %s\n", - ThisSignature, TotalBytesWritten, Filename); + printf ("Acpi table [%4.4s] - %u bytes written to %s\n", + ThisSignature, (unsigned int) TotalBytesWritten, Filename); } } fclose (InputFile); - return 0; + return (Status); } @@ -633,11 +698,16 @@ ExtractTables ( * * FUNCTION: ListTables * - * DESCRIPTION: Display info for all ACPI tables found in input + * PARAMETERS: InputPathname - Filename for acpidump file + * + * RETURN: Status + * + * DESCRIPTION: Display info for all ACPI tables found in input. Does not + * perform an actual extraction of the tables. * ******************************************************************************/ -int +static int ListTables ( char *InputPathname) { @@ -646,6 +716,7 @@ ListTables ( size_t HeaderSize; unsigned char Header[48]; int TableCount = 0; + ACPI_TABLE_HEADER *TableHeader = (ACPI_TABLE_HEADER *) (void *) Header; /* Open input in text mode, output is in binary mode */ @@ -654,10 +725,13 @@ ListTables ( if (!InputFile) { printf ("Could not open %s\n", InputPathname); - return -1; + return (-1); } - printf ("\nSignature Length OemId OemTableId OemRevision CompilerId CompilerRevision\n\n"); + /* Dump the headers for all tables found in the input file */ + + printf ("\nSignature Length Revision OemId OemTableId" + " OemRevision CompilerId CompilerRevision\n\n"); while (fgets (Buffer, BUFFER_SIZE, InputFile)) { @@ -679,15 +753,15 @@ ListTables ( /* RSDP has an oddball signature and header */ - if (!strncmp ((char *) Header, "RSD PTR ", 8)) + if (!strncmp (TableHeader->Signature, "RSD PTR ", 8)) { - CheckAscii (&Header[9], 6); - printf ("%8.4s \"%6.6s\"\n", "RSDP", &Header[9]); + CheckAscii ((char *) &Header[9], 6); + printf ("%8.4s \"%6.6s\"\n", "RSDP", &Header[9]); TableCount++; continue; } - /* Minimum size */ + /* Minimum size for table with standard header */ if (HeaderSize < 36) { @@ -697,11 +771,11 @@ ListTables ( /* Signature and Table length */ TableCount++; - printf ("%8.4s % 7d", Header, *(int *) &Header[4]); + printf ("%8.4s % 7d", TableHeader->Signature, TableHeader->Length); /* FACS has only signature and length */ - if (!strncmp ((char *) Header, "FACS", 4)) + if (!strncmp (TableHeader->Signature, "FACS", 4)) { printf ("\n"); continue; @@ -709,18 +783,19 @@ ListTables ( /* OEM IDs and Compiler IDs */ - CheckAscii (&Header[10], 6); - CheckAscii (&Header[16], 8); - CheckAscii (&Header[28], 4); + CheckAscii (TableHeader->OemId, 6); + CheckAscii (TableHeader->OemTableId, 8); + CheckAscii (TableHeader->AslCompilerId, 4); - printf (" \"%6.6s\" \"%8.8s\" %8.8X \"%4.4s\" %8.8X\n", - &Header[10], &Header[16], *(int *) &Header[24], - &Header[28], *(int *) &Header[32]); + printf (" %2.2X \"%6.6s\" \"%8.8s\" %8.8X \"%4.4s\" %8.8X\n", + TableHeader->Revision, TableHeader->OemId, + TableHeader->OemTableId, TableHeader->OemRevision, + TableHeader->AslCompilerId, TableHeader->AslCompilerRevision); } - printf ("\nFound %d ACPI tables [%8.8X]\n", TableCount, VERSION); + printf ("\nFound %u ACPI tables [%8.8X]\n", TableCount, VERSION); fclose (InputFile); - return 0; + return (0); } @@ -743,7 +818,7 @@ main ( if (argc < 2) { DisplayUsage (); - return 0; + return (0); } if (argv[1][0] == '-') @@ -751,23 +826,32 @@ main ( if (argc < 3) { DisplayUsage (); - return 0; + return (0); } switch (argv[1][1]) { case 'a': + + /* Extract all tables found */ + return (ExtractTables (argv[2], NULL, 0)); case 'l': + + /* List tables only, do not extract */ + return (ListTables (argv[2])); case 's': + + /* Extract only tables with this signature */ + return (ExtractTables (argv[2], &argv[1][2], 1)); default: DisplayUsage (); - return 0; + return (0); } } @@ -778,7 +862,7 @@ main ( Status = ExtractTables (argv[1], "DSDT", 1); if (Status) { - return Status; + return (Status); } Status = ExtractTables (argv[1], "SSDT", 0); diff --git a/sys/contrib/dev/acpica-unix/tools/examples/examples.c b/sys/contrib/dev/acpica-unix/tools/examples/examples.c index e2dfacd20d..b85d24c4db 100644 --- a/sys/contrib/dev/acpica-unix/tools/examples/examples.c +++ b/sys/contrib/dev/acpica-unix/tools/examples/examples.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -393,7 +393,7 @@ NotifyHandler ( void *Context) { - ACPI_INFO ((AE_INFO, "Received a notify %X", Value)); + ACPI_INFO ((AE_INFO, "Received a notify 0x%X", Value)); } @@ -482,7 +482,7 @@ ExecuteOSI (void) AcpiOsPrintf ("Invalid return type from _OSI, %.2X\n", Object->Type); } - ACPI_INFO ((AE_INFO, "_OSI returned %.8X", (UINT32) Object->Integer.Value)); + ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", (UINT32) Object->Integer.Value)); AcpiOsFree (Object); return; } diff --git a/sys/contrib/dev/acpica-unix/utilities/utalloc.c b/sys/contrib/dev/acpica-unix/utilities/utalloc.c index a66b94005c..7a276f8203 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utalloc.c +++ b/sys/contrib/dev/acpica-unix/utilities/utalloc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -438,7 +438,7 @@ AcpiUtAllocate ( /* Report allocation error */ ACPI_WARNING ((Module, Line, - "Could not allocate size %X", (UINT32) Size)); + "Could not allocate size %u", (UINT32) Size)); return_PTR (NULL); } diff --git a/sys/contrib/dev/acpica-unix/utilities/utcache.c b/sys/contrib/dev/acpica-unix/utilities/utcache.c index aabc0a2305..ba131014b6 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utcache.c +++ b/sys/contrib/dev/acpica-unix/utilities/utcache.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/utilities/utclib.c b/sys/contrib/dev/acpica-unix/utilities/utclib.c index a9b8122fab..340e5b5d4a 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utclib.c +++ b/sys/contrib/dev/acpica-unix/utilities/utclib.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/utilities/utcopy.c b/sys/contrib/dev/acpica-unix/utilities/utcopy.c index 20a0e34324..64484ad023 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utcopy.c +++ b/sys/contrib/dev/acpica-unix/utilities/utcopy.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -422,11 +422,11 @@ AcpiUtCopyIelementToEelement ( * RETURN: Status * * DESCRIPTION: This function is called to place a package object in a user - * buffer. A package object by definition contains other objects. + * buffer. A package object by definition contains other objects. * * The buffer is assumed to have sufficient space for the object. - * The caller must have verified the buffer length needed using the - * AcpiUtGetObjectSize function before calling this function. + * The caller must have verified the buffer length needed using + * the AcpiUtGetObjectSize function before calling this function. * ******************************************************************************/ @@ -485,12 +485,12 @@ AcpiUtCopyIpackageToEpackage ( * FUNCTION: AcpiUtCopyIobjectToEobject * * PARAMETERS: InternalObject - The internal object to be converted - * BufferPtr - Where the object is returned + * RetBuffer - Where the object is returned * * RETURN: Status * - * DESCRIPTION: This function is called to build an API object to be returned to - * the caller. + * DESCRIPTION: This function is called to build an API object to be returned + * to the caller. * ******************************************************************************/ @@ -742,7 +742,7 @@ AcpiUtCopyEpackageToIpackage ( * PARAMETERS: ExternalObject - The external object to be converted * InternalObject - Where the internal object is returned * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: Converts an external object to an internal object. * @@ -784,7 +784,7 @@ AcpiUtCopyEobjectToIobject ( * * RETURN: Status * - * DESCRIPTION: Simple copy of one internal object to another. Reference count + * DESCRIPTION: Simple copy of one internal object to another. Reference count * of the destination object is preserved. * ******************************************************************************/ @@ -797,6 +797,7 @@ AcpiUtCopySimpleObject ( UINT16 ReferenceCount; ACPI_OPERAND_OBJECT *NextObject; ACPI_STATUS Status; + ACPI_SIZE CopySize; /* Save fields from destination that we don't want to overwrite */ @@ -804,10 +805,18 @@ AcpiUtCopySimpleObject ( ReferenceCount = DestDesc->Common.ReferenceCount; NextObject = DestDesc->Common.NextObject; - /* Copy the entire source object over the destination object*/ + /* + * Copy the entire source object over the destination object. + * Note: Source can be either an operand object or namespace node. + */ + CopySize = sizeof (ACPI_OPERAND_OBJECT); + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + CopySize = sizeof (ACPI_NAMESPACE_NODE); + } - ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, - sizeof (ACPI_OPERAND_OBJECT)); + ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc), + ACPI_CAST_PTR (char, SourceDesc), CopySize); /* Restore the saved fields */ @@ -841,8 +850,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual buffer data */ ACPI_MEMCPY (DestDesc->Buffer.Pointer, - SourceDesc->Buffer.Pointer, - SourceDesc->Buffer.Length); + SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length); } break; @@ -864,7 +872,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual string data */ ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, - (ACPI_SIZE) SourceDesc->String.Length + 1); + (ACPI_SIZE) SourceDesc->String.Length + 1); } break; @@ -1034,10 +1042,11 @@ ErrorExit: * * FUNCTION: AcpiUtCopyIpackageToIpackage * - * PARAMETERS: *SourceObj - Pointer to the source package object - * *DestObj - Where the internal object is returned + * PARAMETERS: SourceObj - Pointer to the source package object + * DestObj - Where the internal object is returned + * WalkState - Current Walk state descriptor * - * RETURN: Status - the status of the call + * RETURN: Status * * DESCRIPTION: This function is called to copy an internal package object * into another internal package object. @@ -1093,9 +1102,9 @@ AcpiUtCopyIpackageToIpackage ( * * FUNCTION: AcpiUtCopyIobjectToIobject * - * PARAMETERS: WalkState - Current walk state - * SourceDesc - The internal object to be copied + * PARAMETERS: SourceDesc - The internal object to be copied * DestDesc - Where the copied object is returned + * WalkState - Current walk state * * RETURN: Status * diff --git a/sys/contrib/dev/acpica-unix/utilities/utdebug.c b/sys/contrib/dev/acpica-unix/utilities/utdebug.c index 3901b07d19..b21f07fc9e 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utdebug.c +++ b/sys/contrib/dev/acpica-unix/utilities/utdebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -279,9 +279,8 @@ AcpiDebugPrint ( if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ( - "\n**** Context Switch from TID %p to TID %p ****\n\n", - ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId), - ACPI_CAST_PTR (void, ThreadId)); + "\n**** Context Switch from TID %u to TID %u ****\n\n", + (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId); } AcpiGbl_PrevThreadId = ThreadId; @@ -295,7 +294,7 @@ AcpiDebugPrint ( if (ACPI_LV_THREADS & AcpiDbgLevel) { - AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId)); + AcpiOsPrintf ("[%u] ", (UINT32) ThreadId); } AcpiOsPrintf ("[%02ld] %-22.22s: ", @@ -598,7 +597,7 @@ AcpiUtValueExit ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - ACPI_INTEGER Value) + UINT64 Value) { AcpiDebugPrint (ACPI_LV_FUNCTIONS, diff --git a/sys/contrib/dev/acpica-unix/utilities/utglobal.c b/sys/contrib/dev/acpica-unix/utilities/utdecode.c similarity index 63% copy from sys/contrib/dev/acpica-unix/utilities/utglobal.c copy to sys/contrib/dev/acpica-unix/utilities/utdecode.c index c40a900138..b14d399426 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utglobal.c +++ b/sys/contrib/dev/acpica-unix/utilities/utdecode.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: utglobal - Global variables for the ACPI subsystem + * Module Name: utdecode - Utility decoding routines (value-to-string) * *****************************************************************************/ @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -113,72 +113,14 @@ * *****************************************************************************/ -#define __UTGLOBAL_C__ -#define DEFINE_ACPI_GLOBALS +#define __UTDECODE_C__ #include "acpi.h" #include "accommon.h" #include "acnamesp.h" #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utglobal") - - -/******************************************************************************* - * - * Static global variable initialization. - * - ******************************************************************************/ - -/* - * We want the debug switches statically initialized so they - * are already set when the debugger is entered. - */ - -/* Debug switch - level and trace mask */ - -#ifdef ACPI_DEBUG_OUTPUT -UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; -#else -UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; -#endif - -/* Debug switch - layer (component) mask */ - -UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; -UINT32 AcpiGbl_NestingLevel = 0; - -/* Debugger globals */ - -BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; -BOOLEAN AcpiGbl_AbortMethod = FALSE; -BOOLEAN AcpiGbl_MethodExecuting = FALSE; - -/* System flags */ - -UINT32 AcpiGbl_StartupFlags = 0; - -/* System starts uninitialized */ - -BOOLEAN AcpiGbl_Shutdown = TRUE; - -const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = -{ - "\\_S0_", - "\\_S1_", - "\\_S2_", - "\\_S3_", - "\\_S4_", - "\\_S5_" -}; - -const char *AcpiGbl_HighestDstateNames[4] = -{ - "_S1D", - "_S2D", - "_S3D", - "_S4D" -}; + ACPI_MODULE_NAME ("utdecode") /******************************************************************************* @@ -222,41 +164,6 @@ AcpiFormatException ( ACPI_EXPORT_SYMBOL (AcpiFormatException) -/******************************************************************************* - * - * Namespace globals - * - ******************************************************************************/ - -/* - * Predefined ACPI Names (Built-in to the Interpreter) - * - * NOTES: - * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run - * during the initialization sequence. - * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to - * perform a Notify() operation on it. - */ -const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = -{ - {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_SB_", ACPI_TYPE_DEVICE, NULL}, - {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_THERMAL, NULL}, - {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, - {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, - -#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, -#endif - - /* Table terminator */ - - {NULL, ACPI_TYPE_ANY, NULL} -}; - /* * Properties of the ACPI Object Types, both internal and external. * The table is indexed by values of ACPI_OBJECT_TYPE @@ -297,15 +204,6 @@ const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = }; -/* Hex to ASCII conversion table */ - -static const char AcpiGbl_HexToAscii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' -}; - - /******************************************************************************* * * FUNCTION: AcpiUtHexToAsciiChar @@ -320,9 +218,17 @@ static const char AcpiGbl_HexToAscii[] = * ******************************************************************************/ +/* Hex to ASCII conversion table */ + +static const char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + char AcpiUtHexToAsciiChar ( - ACPI_INTEGER Integer, + UINT64 Integer, UINT32 Position) { @@ -330,58 +236,13 @@ AcpiUtHexToAsciiChar ( } -/****************************************************************************** - * - * Event and Hardware globals - * - ******************************************************************************/ - -ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = -{ - /* Name Parent Register Register Bit Position Register Bit Mask */ - - /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, - /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, - /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, - /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, - /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, - /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, - /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, - /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, - - /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, - /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, - - /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, - /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, - /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, - /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, - /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, - - /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} -}; - - -ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = -{ - /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, - /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, - /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, - /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, - /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, -}; - /******************************************************************************* * * FUNCTION: AcpiUtGetRegionName * - * PARAMETERS: None. + * PARAMETERS: Space ID - ID for the region * - * RETURN: Status + * RETURN: Decoded region SpaceId name * * DESCRIPTION: Translate a Space ID into a name string (Debug only) * @@ -398,6 +259,7 @@ const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = "SMBus", "SystemCMOS", "PCIBARTarget", + "IPMI", "DataTable" }; @@ -411,6 +273,10 @@ AcpiUtGetRegionName ( { return ("UserDefinedRegion"); } + else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE) + { + return ("FunctionalFixedHW"); + } else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) { return ("InvalidSpaceId"); @@ -424,9 +290,9 @@ AcpiUtGetRegionName ( * * FUNCTION: AcpiUtGetEventName * - * PARAMETERS: None. + * PARAMETERS: EventId - Fixed event ID * - * RETURN: Status + * RETURN: Decoded event ID name * * DESCRIPTION: Translate a Event ID into a name string (Debug only) * @@ -462,9 +328,9 @@ AcpiUtGetEventName ( * * FUNCTION: AcpiUtGetTypeName * - * PARAMETERS: None. + * PARAMETERS: Type - An ACPI object type * - * RETURN: Status + * RETURN: Decoded ACPI object type name * * DESCRIPTION: Translate a Type ID into a name string (Debug only) * @@ -552,7 +418,7 @@ AcpiUtGetObjectTypeName ( * * PARAMETERS: Object - A namespace node * - * RETURN: Pointer to a string + * RETURN: ASCII name of the node * * DESCRIPTION: Validate the node and return the node's ACPI name. * @@ -605,7 +471,7 @@ AcpiUtGetNodeName ( * * PARAMETERS: Object - An ACPI object * - * RETURN: Pointer to a string + * RETURN: Decoded name of the descriptor type * * DESCRIPTION: Validate object and return the descriptor type * @@ -615,7 +481,7 @@ AcpiUtGetNodeName ( static const char *AcpiGbl_DescTypeNames[] = { - /* 00 */ "Invalid", + /* 00 */ "Not a Descriptor", /* 01 */ "Cached", /* 02 */ "State-Generic", /* 03 */ "State-Update", @@ -646,7 +512,7 @@ AcpiUtGetDescriptorName ( if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) { - return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + return ("Not a Descriptor"); } return (ACPI_CAST_PTR (char, @@ -661,7 +527,7 @@ AcpiUtGetDescriptorName ( * * PARAMETERS: Object - An ACPI reference object * - * RETURN: Pointer to a string + * RETURN: Decoded name of the type of reference * * DESCRIPTION: Decode a reference object sub-type to a string. * @@ -720,13 +586,26 @@ AcpiUtGetReferenceName ( * * PARAMETERS: MutexId - The predefined ID for this mutex. * - * RETURN: String containing the name of the mutex. Always returns a valid - * pointer. + * RETURN: Decoded name of the internal mutex * * DESCRIPTION: Translate a mutex ID into a name string (Debug only) * ******************************************************************************/ +/* Names for internal mutex objects, used for debug output */ + +static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = +{ + "ACPI_MTX_Interpreter", + "ACPI_MTX_Namespace", + "ACPI_MTX_Tables", + "ACPI_MTX_Events", + "ACPI_MTX_Caches", + "ACPI_MTX_Memory", + "ACPI_MTX_CommandComplete", + "ACPI_MTX_CommandReady" +}; + char * AcpiUtGetMutexName ( UINT32 MutexId) @@ -747,7 +626,7 @@ AcpiUtGetMutexName ( * * PARAMETERS: NotifyValue - Value from the Notify() request * - * RETURN: String corresponding to the Notify Value. + * RETURN: Decoded name for the notify value * * DESCRIPTION: Translate a Notify Value to a notify namestring. * @@ -755,7 +634,7 @@ AcpiUtGetMutexName ( /* Names for Notify() values, used for debug output */ -static const char *AcpiGbl_NotifyValueNames[] = +static const char *AcpiGbl_NotifyValueNames[] = { "Bus Check", "Device Check", @@ -818,143 +697,3 @@ AcpiUtValidObjectType ( return (TRUE); } - - -/******************************************************************************* - * - * FUNCTION: AcpiUtInitGlobals - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Init library globals. All globals that require specific - * initialization should be initialized here! - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtInitGlobals ( - void) -{ - ACPI_STATUS Status; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtInitGlobals); - - - /* Create all memory caches */ - - Status = AcpiUtCreateCaches (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Mutex locked flags */ - - for (i = 0; i < ACPI_NUM_MUTEX; i++) - { - AcpiGbl_MutexInfo[i].Mutex = NULL; - AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - AcpiGbl_MutexInfo[i].UseCount = 0; - } - - for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) - { - AcpiGbl_OwnerIdMask[i] = 0; - } - - /* Last OwnerID is never valid */ - - AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; - - /* Event counters */ - - AcpiMethodCount = 0; - AcpiSciCount = 0; - AcpiGpeCount = 0; - - for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) - { - AcpiFixedEventCount[i] = 0; - } - - /* GPE support */ - - AcpiGbl_GpeXruptListHead = NULL; - AcpiGbl_GpeFadtBlocks[0] = NULL; - AcpiGbl_GpeFadtBlocks[1] = NULL; - AcpiCurrentGpeCount = 0; - - /* Global handlers */ - - AcpiGbl_SystemNotify.Handler = NULL; - AcpiGbl_DeviceNotify.Handler = NULL; - AcpiGbl_ExceptionHandler = NULL; - AcpiGbl_InitHandler = NULL; - AcpiGbl_TableHandler = NULL; - - /* Global Lock support */ - - AcpiGbl_GlobalLockSemaphore = NULL; - AcpiGbl_GlobalLockMutex = NULL; - AcpiGbl_GlobalLockAcquired = FALSE; - AcpiGbl_GlobalLockHandle = 0; - AcpiGbl_GlobalLockPresent = FALSE; - - /* Miscellaneous variables */ - - AcpiGbl_CmSingleStep = FALSE; - AcpiGbl_DbTerminateThreads = FALSE; - AcpiGbl_Shutdown = FALSE; - AcpiGbl_NsLookupCount = 0; - AcpiGbl_PsFindCount = 0; - AcpiGbl_AcpiHardwarePresent = TRUE; - AcpiGbl_LastOwnerIdIndex = 0; - AcpiGbl_NextOwnerIdOffset = 0; - AcpiGbl_TraceMethodName = 0; - AcpiGbl_TraceDbgLevel = 0; - AcpiGbl_TraceDbgLayer = 0; - AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; - AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_OsiData = 0; - - /* Hardware oriented */ - - AcpiGbl_EventsInitialized = FALSE; - AcpiGbl_SystemAwakeAndRunning = TRUE; - - /* Namespace */ - - AcpiGbl_RootNode = NULL; - AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; - AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; - AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; - AcpiGbl_RootNodeStruct.Child = NULL; - AcpiGbl_RootNodeStruct.Peer = NULL; - AcpiGbl_RootNodeStruct.Object = NULL; - AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; - - -#ifdef ACPI_DEBUG_OUTPUT - AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); -#endif - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiGbl_DisplayFinalMemStats = FALSE; -#endif - - return_ACPI_STATUS (AE_OK); -} - -/* Public globals */ - -ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) -ACPI_EXPORT_SYMBOL (AcpiDbgLevel) -ACPI_EXPORT_SYMBOL (AcpiDbgLayer) -ACPI_EXPORT_SYMBOL (AcpiGpeCount) -ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) - - diff --git a/sys/contrib/dev/acpica-unix/utilities/utdelete.c b/sys/contrib/dev/acpica-unix/utilities/utdelete.c index bf30aee74e..801f957d49 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utdelete.c +++ b/sys/contrib/dev/acpica-unix/utilities/utdelete.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -539,7 +539,7 @@ AcpiUtUpdateRefCount ( default: - ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); + ACPI_ERROR ((AE_INFO, "Unknown action (0x%X)", Action)); break; } @@ -550,7 +550,7 @@ AcpiUtUpdateRefCount ( if (Count > ACPI_MAX_REFERENCE_COUNT) { ACPI_WARNING ((AE_INFO, - "Large Reference Count (%X) in object %p", Count, Object)); + "Large Reference Count (0x%X) in object %p", Count, Object)); } } diff --git a/sys/contrib/dev/acpica-unix/utilities/uteval.c b/sys/contrib/dev/acpica-unix/utilities/uteval.c index a75ef3caf6..eeaaebbbe0 100644 --- a/sys/contrib/dev/acpica-unix/utilities/uteval.c +++ b/sys/contrib/dev/acpica-unix/utilities/uteval.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -118,155 +118,11 @@ #include "acpi.h" #include "accommon.h" #include "acnamesp.h" -#include "acinterp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("uteval") -/* Local prototypes */ - -static void -AcpiUtCopyIdString ( - char *Destination, - char *Source, - ACPI_SIZE MaxLength); - -static ACPI_STATUS -AcpiUtTranslateOneCid ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_COMPATIBLE_ID *OneCid); - - -/* - * Strings supported by the _OSI predefined (internal) method. - * - * March 2009: Removed "Linux" as this host no longer wants to respond true - * for this string. Basically, the only safe OS strings are windows-related - * and in many or most cases represent the only test path within the - * BIOS-provided ASL code. - * - * The second element of each entry is used to track the newest version of - * Windows that the BIOS has requested. - */ -static const ACPI_INTERFACE_INFO AcpiInterfacesSupported[] = -{ - /* Operating System Vendor Strings */ - - {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ - {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ - {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ - {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ - {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ - {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ - {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ - - /* Feature Group Strings */ - - {"Extended Address Space Descriptor", 0} - - /* - * All "optional" feature group strings (features that are implemented - * by the host) should be implemented in the host version of - * AcpiOsValidateInterface and should not be added here. - */ -}; - - -/******************************************************************************* - * - * FUNCTION: AcpiUtOsiImplementation - * - * PARAMETERS: WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Implementation of the _OSI predefined control method - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtOsiImplementation ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *StringDesc; - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT32 ReturnValue; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtOsiImplementation); - - - /* Validate the string input argument */ - - StringDesc = WalkState->Arguments[0].Object; - if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING)) - { - return_ACPI_STATUS (AE_TYPE); - } - - /* Create a return object */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Default return value is 0, NOT SUPPORTED */ - - ReturnValue = 0; - - /* Compare input string to static table of supported interfaces */ - - for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++) - { - if (!ACPI_STRCMP (StringDesc->String.Pointer, - AcpiInterfacesSupported[i].Name)) - { - /* - * The interface is supported. - * Update the OsiData if necessary. We keep track of the latest - * version of Windows that has been requested by the BIOS. - */ - if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData) - { - AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value; - } - - ReturnValue = ACPI_UINT32_MAX; - goto Exit; - } - } - - /* - * Did not match the string in the static table, call the host OSL to - * check for a match with one of the optional strings (such as - * "Module Device", "3.0 Thermal Model", etc.) - */ - Status = AcpiOsValidateInterface (StringDesc->String.Pointer); - if (ACPI_SUCCESS (Status)) - { - /* The interface is supported */ - - ReturnValue = ACPI_UINT32_MAX; - } - - -Exit: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, - "ACPI: BIOS _OSI(%s) is %ssupported\n", - StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); - - /* Complete the return value */ - - ReturnDesc->Integer.Value = ReturnValue; - WalkState->ReturnDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - /******************************************************************************* * @@ -280,7 +136,7 @@ Exit: * RETURN: Status * * DESCRIPTION: Evaluates a namespace object and verifies the type of the - * return object. Common code that simplifies accessing objects + * return object. Common code that simplifies accessing objects * that have required return objects of fixed types. * * NOTE: Internal function, no parameter validation @@ -376,7 +232,7 @@ AcpiUtEvaluateObject ( (!ExpectedReturnBtypes)) { /* - * We received a return object, but one was not expected. This can + * We received a return object, but one was not expected. This can * happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ @@ -392,7 +248,7 @@ AcpiUtEvaluateObject ( PrefixNode, Path, AE_TYPE); ACPI_ERROR ((AE_INFO, - "Type returned from %s was incorrect: %s, expected Btypes: %X", + "Type returned from %s was incorrect: %s, expected Btypes: 0x%X", Path, AcpiUtGetObjectTypeName (Info->ReturnObject), ExpectedReturnBtypes)); @@ -419,12 +275,12 @@ Cleanup: * * PARAMETERS: ObjectName - Object name to be evaluated * DeviceNode - Node for the device - * Address - Where the value is returned + * Value - Where the value is returned * * RETURN: Status * * DESCRIPTION: Evaluates a numeric namespace object for a selected device - * and stores result in *Address. + * and stores result in *Value. * * NOTE: Internal function, no parameter validation * @@ -434,7 +290,7 @@ ACPI_STATUS AcpiUtEvaluateNumericObject ( char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_INTEGER *Address) + UINT64 *Value) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; @@ -452,326 +308,7 @@ AcpiUtEvaluateNumericObject ( /* Get the returned Integer */ - *Address = ObjDesc->Integer.Value; - - /* On exit, we must delete the return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCopyIdString - * - * PARAMETERS: Destination - Where to copy the string - * Source - Source string - * MaxLength - Length of the destination buffer - * - * RETURN: None - * - * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. - * Performs removal of a leading asterisk if present -- workaround - * for a known issue on a bunch of machines. - * - ******************************************************************************/ - -static void -AcpiUtCopyIdString ( - char *Destination, - char *Source, - ACPI_SIZE MaxLength) -{ - - /* - * Workaround for ID strings that have a leading asterisk. This construct - * is not allowed by the ACPI specification (ID strings must be - * alphanumeric), but enough existing machines have this embedded in their - * ID strings that the following code is useful. - */ - if (*Source == '*') - { - Source++; - } - - /* Do the actual copy */ - - ACPI_STRNCPY (Destination, Source, MaxLength); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_HID - * - * PARAMETERS: DeviceNode - Node for the device - * Hid - Where the HID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _HID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_HID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Hid) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (UtExecute_HID); - - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric HID to string */ - - AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value); - } - else - { - /* Copy the String HID from the returned object */ - - AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer, - sizeof (Hid->Value)); - } - - /* On exit, we must delete the return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtTranslateOneCid - * - * PARAMETERS: ObjDesc - _CID object, must be integer or string - * OneCid - Where the CID string is returned - * - * RETURN: Status - * - * DESCRIPTION: Return a numeric or string _CID value as a string. - * (Compatible ID) - * - * NOTE: Assumes a maximum _CID string length of - * ACPI_MAX_CID_LENGTH. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtTranslateOneCid ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_COMPATIBLE_ID *OneCid) -{ - - - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Convert the Numeric CID to string */ - - AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value); - return (AE_OK); - - case ACPI_TYPE_STRING: - - if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH) - { - return (AE_AML_STRING_LIMIT); - } - - /* Copy the String CID from the returned object */ - - AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer, - ACPI_MAX_CID_LENGTH); - return (AE_OK); - - default: - - return (AE_TYPE); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_CID - * - * PARAMETERS: DeviceNode - Node for the device - * ReturnCidList - Where the CID list is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _CID control method that returns one or more - * compatible hardware IDs for the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_CID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_COMPATIBLE_ID_LIST **ReturnCidList) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - UINT32 Count; - UINT32 Size; - ACPI_COMPATIBLE_ID_LIST *CidList; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtExecute_CID); - - - /* Evaluate the _CID method for this device */ - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, - &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the number of _CIDs returned */ - - Count = 1; - if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - Count = ObjDesc->Package.Count; - } - - /* Allocate a worst-case buffer for the _CIDs */ - - Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) + - sizeof (ACPI_COMPATIBLE_ID_LIST)); - - CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size); - if (!CidList) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Init CID list */ - - CidList->Count = Count; - CidList->Size = Size; - - /* - * A _CID can return either a single compatible ID or a package of - * compatible IDs. Each compatible ID can be one of the following: - * 1) Integer (32 bit compressed EISA ID) or - * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") - */ - - /* The _CID object can be either a single CID or a package (list) of CIDs */ - - if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Translate each package element */ - - for (i = 0; i < Count; i++) - { - Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i], - &CidList->Id[i]); - if (ACPI_FAILURE (Status)) - { - break; - } - } - } - else - { - /* Only one CID, translate to a string */ - - Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id); - } - - /* Cleanup on error */ - - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (CidList); - } - else - { - *ReturnCidList = CidList; - } - - /* On exit, we must delete the _CID return object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtExecute_UID - * - * PARAMETERS: DeviceNode - Node for the device - * Uid - Where the UID is returned - * - * RETURN: Status - * - * DESCRIPTION: Executes the _UID control method that returns the hardware - * ID of the device. - * - * NOTE: Internal function, no parameter validation - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtExecute_UID ( - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_DEVICE_ID *Uid) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (UtExecute_UID); - - - Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, - ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric UID to string */ - - AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value); - } - else - { - /* Copy the String UID from the returned object */ - - AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer, - sizeof (Uid->Value)); - } + *Value = ObjDesc->Integer.Value; /* On exit, we must delete the return object */ @@ -838,63 +375,68 @@ AcpiUtExecute_STA ( /******************************************************************************* * - * FUNCTION: AcpiUtExecute_Sxds + * FUNCTION: AcpiUtExecutePowerMethods * * PARAMETERS: DeviceNode - Node for the device - * Flags - Where the status flags are returned + * MethodNames - Array of power method names + * MethodCount - Number of methods to execute + * OutValues - Where the power method values are returned * - * RETURN: Status + * RETURN: Status, OutValues * - * DESCRIPTION: Executes _STA for selected device and stores results in - * *Flags. + * DESCRIPTION: Executes the specified power methods for the device and returns + * the result(s). * * NOTE: Internal function, no parameter validation * ******************************************************************************/ ACPI_STATUS -AcpiUtExecute_Sxds ( +AcpiUtExecutePowerMethods ( ACPI_NAMESPACE_NODE *DeviceNode, - UINT8 *Highest) + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_STATUS FinalStatus = AE_NOT_FOUND; UINT32 i; - ACPI_FUNCTION_TRACE (UtExecute_Sxds); + ACPI_FUNCTION_TRACE (UtExecutePowerMethods); - for (i = 0; i < 4; i++) + for (i = 0; i < MethodCount; i++) { - Highest[i] = 0xFF; + /* + * Execute the power method (_SxD or _SxW). The only allowable + * return type is an Integer. + */ Status = AcpiUtEvaluateObject (DeviceNode, - ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]), + ACPI_CAST_PTR (char, MethodNames[i]), ACPI_BTYPE_INTEGER, &ObjDesc); - if (ACPI_FAILURE (Status)) - { - if (Status != AE_NOT_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%s on Device %4.4s, %s\n", - ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]), - AcpiUtGetNodeName (DeviceNode), - AcpiFormatException (Status))); - - return_ACPI_STATUS (Status); - } - } - else + if (ACPI_SUCCESS (Status)) { - /* Extract the Dstate value */ - - Highest[i] = (UINT8) ObjDesc->Integer.Value; + OutValues[i] = (UINT8) ObjDesc->Integer.Value; /* Delete the return object */ AcpiUtRemoveReference (ObjDesc); + FinalStatus = AE_OK; /* At least one value is valid */ + continue; + } + + OutValues[i] = ACPI_UINT8_MAX; + if (Status == AE_NOT_FOUND) + { + continue; /* Ignore if not found */ } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n", + ACPI_CAST_PTR (char, MethodNames[i]), + AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status))); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (FinalStatus); } diff --git a/sys/contrib/dev/acpica-unix/utilities/utglobal.c b/sys/contrib/dev/acpica-unix/utilities/utglobal.c index c40a900138..30da582a98 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utglobal.c +++ b/sys/contrib/dev/acpica-unix/utilities/utglobal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -118,7 +118,6 @@ #include "acpi.h" #include "accommon.h" -#include "acnamesp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utglobal") @@ -172,7 +171,16 @@ const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = "\\_S5_" }; -const char *AcpiGbl_HighestDstateNames[4] = +const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = +{ + "_S0W", + "_S1W", + "_S2W", + "_S3W", + "_S4W" +}; + +const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = { "_S1D", "_S2D", @@ -181,47 +189,6 @@ const char *AcpiGbl_HighestDstateNames[4] = }; -/******************************************************************************* - * - * FUNCTION: AcpiFormatException - * - * PARAMETERS: Status - The ACPI_STATUS code to be formatted - * - * RETURN: A string containing the exception text. A valid pointer is - * always returned. - * - * DESCRIPTION: This function translates an ACPI exception into an ASCII string - * It is here instead of utxface.c so it is always present. - * - ******************************************************************************/ - -const char * -AcpiFormatException ( - ACPI_STATUS Status) -{ - const char *Exception = NULL; - - - ACPI_FUNCTION_ENTRY (); - - - Exception = AcpiUtValidateException (Status); - if (!Exception) - { - /* Exception code was not recognized */ - - ACPI_ERROR ((AE_INFO, - "Unknown exception code: 0x%8.8X", Status)); - - Exception = "UNKNOWN_STATUS_CODE"; - } - - return (ACPI_CAST_PTR (const char, Exception)); -} - -ACPI_EXPORT_SYMBOL (AcpiFormatException) - - /******************************************************************************* * * Namespace globals @@ -235,7 +202,9 @@ ACPI_EXPORT_SYMBOL (AcpiFormatException) * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run * during the initialization sequence. * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to - * perform a Notify() operation on it. + * perform a Notify() operation on it. 09/2010: Changed to type Device. + * This still allows notifies, but does not confuse host code that + * searches for valid ThermalZone objects. */ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = { @@ -243,7 +212,7 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_THERMAL, NULL}, + {"_TZ_", ACPI_TYPE_DEVICE, NULL}, {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, @@ -257,78 +226,6 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = {NULL, ACPI_TYPE_ANY, NULL} }; -/* - * Properties of the ACPI Object Types, both internal and external. - * The table is indexed by values of ACPI_OBJECT_TYPE - */ -const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = -{ - ACPI_NS_NORMAL, /* 00 Any */ - ACPI_NS_NORMAL, /* 01 Number */ - ACPI_NS_NORMAL, /* 02 String */ - ACPI_NS_NORMAL, /* 03 Buffer */ - ACPI_NS_NORMAL, /* 04 Package */ - ACPI_NS_NORMAL, /* 05 FieldUnit */ - ACPI_NS_NEWSCOPE, /* 06 Device */ - ACPI_NS_NORMAL, /* 07 Event */ - ACPI_NS_NEWSCOPE, /* 08 Method */ - ACPI_NS_NORMAL, /* 09 Mutex */ - ACPI_NS_NORMAL, /* 10 Region */ - ACPI_NS_NEWSCOPE, /* 11 Power */ - ACPI_NS_NEWSCOPE, /* 12 Processor */ - ACPI_NS_NEWSCOPE, /* 13 Thermal */ - ACPI_NS_NORMAL, /* 14 BufferField */ - ACPI_NS_NORMAL, /* 15 DdbHandle */ - ACPI_NS_NORMAL, /* 16 Debug Object */ - ACPI_NS_NORMAL, /* 17 DefField */ - ACPI_NS_NORMAL, /* 18 BankField */ - ACPI_NS_NORMAL, /* 19 IndexField */ - ACPI_NS_NORMAL, /* 20 Reference */ - ACPI_NS_NORMAL, /* 21 Alias */ - ACPI_NS_NORMAL, /* 22 MethodAlias */ - ACPI_NS_NORMAL, /* 23 Notify */ - ACPI_NS_NORMAL, /* 24 Address Handler */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ - ACPI_NS_NEWSCOPE, /* 27 Scope */ - ACPI_NS_NORMAL, /* 28 Extra */ - ACPI_NS_NORMAL, /* 29 Data */ - ACPI_NS_NORMAL /* 30 Invalid */ -}; - - -/* Hex to ASCII conversion table */ - -static const char AcpiGbl_HexToAscii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' -}; - - -/******************************************************************************* - * - * FUNCTION: AcpiUtHexToAsciiChar - * - * PARAMETERS: Integer - Contains the hex digit - * Position - bit position of the digit within the - * integer (multiple of 4) - * - * RETURN: The converted Ascii character - * - * DESCRIPTION: Convert a hex digit to an Ascii character - * - ******************************************************************************/ - -char -AcpiUtHexToAsciiChar ( - ACPI_INTEGER Integer, - UINT32 Position) -{ - - return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); -} - /****************************************************************************** * @@ -375,450 +272,6 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, }; -/******************************************************************************* - * - * FUNCTION: AcpiUtGetRegionName - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Translate a Space ID into a name string (Debug only) - * - ******************************************************************************/ - -/* Region type decoding */ - -const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = -{ - "SystemMemory", - "SystemIO", - "PCI_Config", - "EmbeddedControl", - "SMBus", - "SystemCMOS", - "PCIBARTarget", - "DataTable" -}; - - -char * -AcpiUtGetRegionName ( - UINT8 SpaceId) -{ - - if (SpaceId >= ACPI_USER_REGION_BEGIN) - { - return ("UserDefinedRegion"); - } - else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) - { - return ("InvalidSpaceId"); - } - - return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetEventName - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Translate a Event ID into a name string (Debug only) - * - ******************************************************************************/ - -/* Event type decoding */ - -static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = -{ - "PM_Timer", - "GlobalLock", - "PowerButton", - "SleepButton", - "RealTimeClock", -}; - - -char * -AcpiUtGetEventName ( - UINT32 EventId) -{ - - if (EventId > ACPI_EVENT_MAX) - { - return ("InvalidEventID"); - } - - return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetTypeName - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Translate a Type ID into a name string (Debug only) - * - ******************************************************************************/ - -/* - * Elements of AcpiGbl_NsTypeNames below must match - * one-to-one with values of ACPI_OBJECT_TYPE - * - * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; - * when stored in a table it really means that we have thus far seen no - * evidence to indicate what type is actually going to be stored for this entry. - */ -static const char AcpiGbl_BadType[] = "UNDEFINED"; - -/* Printable names of the ACPI object types */ - -static const char *AcpiGbl_NsTypeNames[] = -{ - /* 00 */ "Untyped", - /* 01 */ "Integer", - /* 02 */ "String", - /* 03 */ "Buffer", - /* 04 */ "Package", - /* 05 */ "FieldUnit", - /* 06 */ "Device", - /* 07 */ "Event", - /* 08 */ "Method", - /* 09 */ "Mutex", - /* 10 */ "Region", - /* 11 */ "Power", - /* 12 */ "Processor", - /* 13 */ "Thermal", - /* 14 */ "BufferField", - /* 15 */ "DdbHandle", - /* 16 */ "DebugObject", - /* 17 */ "RegionField", - /* 18 */ "BankField", - /* 19 */ "IndexField", - /* 20 */ "Reference", - /* 21 */ "Alias", - /* 22 */ "MethodAlias", - /* 23 */ "Notify", - /* 24 */ "AddrHandler", - /* 25 */ "ResourceDesc", - /* 26 */ "ResourceFld", - /* 27 */ "Scope", - /* 28 */ "Extra", - /* 29 */ "Data", - /* 30 */ "Invalid" -}; - - -char * -AcpiUtGetTypeName ( - ACPI_OBJECT_TYPE Type) -{ - - if (Type > ACPI_TYPE_INVALID) - { - return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); - } - - return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); -} - - -char * -AcpiUtGetObjectTypeName ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - - if (!ObjDesc) - { - return ("[NULL Object Descriptor]"); - } - - return (AcpiUtGetTypeName (ObjDesc->Common.Type)); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetNodeName - * - * PARAMETERS: Object - A namespace node - * - * RETURN: Pointer to a string - * - * DESCRIPTION: Validate the node and return the node's ACPI name. - * - ******************************************************************************/ - -char * -AcpiUtGetNodeName ( - void *Object) -{ - ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; - - - /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ - - if (!Object) - { - return ("NULL"); - } - - /* Check for Root node */ - - if ((Object == ACPI_ROOT_OBJECT) || - (Object == AcpiGbl_RootNode)) - { - return ("\"\\\" "); - } - - /* Descriptor must be a namespace node */ - - if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) - { - return ("####"); - } - - /* - * Ensure name is valid. The name was validated/repaired when the node - * was created, but make sure it has not been corrupted. - */ - AcpiUtRepairName (Node->Name.Ascii); - - /* Return the name */ - - return (Node->Name.Ascii); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetDescriptorName - * - * PARAMETERS: Object - An ACPI object - * - * RETURN: Pointer to a string - * - * DESCRIPTION: Validate object and return the descriptor type - * - ******************************************************************************/ - -/* Printable names of object descriptor types */ - -static const char *AcpiGbl_DescTypeNames[] = -{ - /* 00 */ "Invalid", - /* 01 */ "Cached", - /* 02 */ "State-Generic", - /* 03 */ "State-Update", - /* 04 */ "State-Package", - /* 05 */ "State-Control", - /* 06 */ "State-RootParseScope", - /* 07 */ "State-ParseScope", - /* 08 */ "State-WalkScope", - /* 09 */ "State-Result", - /* 10 */ "State-Notify", - /* 11 */ "State-Thread", - /* 12 */ "Walk", - /* 13 */ "Parser", - /* 14 */ "Operand", - /* 15 */ "Node" -}; - - -char * -AcpiUtGetDescriptorName ( - void *Object) -{ - - if (!Object) - { - return ("NULL OBJECT"); - } - - if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) - { - return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); - } - - return (ACPI_CAST_PTR (char, - AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); - -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetReferenceName - * - * PARAMETERS: Object - An ACPI reference object - * - * RETURN: Pointer to a string - * - * DESCRIPTION: Decode a reference object sub-type to a string. - * - ******************************************************************************/ - -/* Printable names of reference object sub-types */ - -static const char *AcpiGbl_RefClassNames[] = -{ - /* 00 */ "Local", - /* 01 */ "Argument", - /* 02 */ "RefOf", - /* 03 */ "Index", - /* 04 */ "DdbHandle", - /* 05 */ "Named Object", - /* 06 */ "Debug" -}; - -const char * -AcpiUtGetReferenceName ( - ACPI_OPERAND_OBJECT *Object) -{ - - if (!Object) - { - return ("NULL Object"); - } - - if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) - { - return ("Not an Operand object"); - } - - if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) - { - return ("Not a Reference object"); - } - - if (Object->Reference.Class > ACPI_REFCLASS_MAX) - { - return ("Unknown Reference class"); - } - - return (AcpiGbl_RefClassNames[Object->Reference.Class]); -} - - -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -/* - * Strings and procedures used for debug only - */ - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetMutexName - * - * PARAMETERS: MutexId - The predefined ID for this mutex. - * - * RETURN: String containing the name of the mutex. Always returns a valid - * pointer. - * - * DESCRIPTION: Translate a mutex ID into a name string (Debug only) - * - ******************************************************************************/ - -char * -AcpiUtGetMutexName ( - UINT32 MutexId) -{ - - if (MutexId > ACPI_MAX_MUTEX) - { - return ("Invalid Mutex ID"); - } - - return (AcpiGbl_MutexNames[MutexId]); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtGetNotifyName - * - * PARAMETERS: NotifyValue - Value from the Notify() request - * - * RETURN: String corresponding to the Notify Value. - * - * DESCRIPTION: Translate a Notify Value to a notify namestring. - * - ******************************************************************************/ - -/* Names for Notify() values, used for debug output */ - -static const char *AcpiGbl_NotifyValueNames[] = -{ - "Bus Check", - "Device Check", - "Device Wake", - "Eject Request", - "Device Check Light", - "Frequency Mismatch", - "Bus Mode Mismatch", - "Power Fault", - "Capabilities Check", - "Device PLD Check", - "Reserved", - "System Locality Update" -}; - -const char * -AcpiUtGetNotifyName ( - UINT32 NotifyValue) -{ - - if (NotifyValue <= ACPI_NOTIFY_MAX) - { - return (AcpiGbl_NotifyValueNames[NotifyValue]); - } - else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) - { - return ("Reserved"); - } - else /* Greater or equal to 0x80 */ - { - return ("**Device Specific**"); - } -} -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiUtValidObjectType - * - * PARAMETERS: Type - Object type to be validated - * - * RETURN: TRUE if valid object type, FALSE otherwise - * - * DESCRIPTION: Validate an object type - * - ******************************************************************************/ - -BOOLEAN -AcpiUtValidObjectType ( - ACPI_OBJECT_TYPE Type) -{ - - if (Type > ACPI_TYPE_LOCAL_MAX) - { - /* Note: Assumes all TYPEs are contiguous (external/local) */ - - return (FALSE); - } - - return (TRUE); -} - /******************************************************************************* * @@ -828,7 +281,7 @@ AcpiUtValidObjectType ( * * RETURN: Status * - * DESCRIPTION: Init library globals. All globals that require specific + * DESCRIPTION: Init ACPICA globals. All globals that require specific * initialization should be initialized here! * ******************************************************************************/ @@ -883,6 +336,7 @@ AcpiUtInitGlobals ( /* GPE support */ + AcpiGbl_AllGpesInitialized = FALSE; AcpiGbl_GpeXruptListHead = NULL; AcpiGbl_GpeFadtBlocks[0] = NULL; AcpiGbl_GpeFadtBlocks[1] = NULL; @@ -895,6 +349,8 @@ AcpiUtInitGlobals ( AcpiGbl_ExceptionHandler = NULL; AcpiGbl_InitHandler = NULL; AcpiGbl_TableHandler = NULL; + AcpiGbl_InterfaceHandler = NULL; + AcpiGbl_GlobalEventHandler = NULL; /* Global Lock support */ @@ -906,6 +362,7 @@ AcpiUtInitGlobals ( /* Miscellaneous variables */ + AcpiGbl_DSDT = NULL; AcpiGbl_CmSingleStep = FALSE; AcpiGbl_DbTerminateThreads = FALSE; AcpiGbl_Shutdown = FALSE; @@ -920,6 +377,8 @@ AcpiUtInitGlobals ( AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; AcpiGbl_OsiData = 0; + AcpiGbl_OsiMutex = NULL; + AcpiGbl_RegMethodsExecuted = FALSE; /* Hardware oriented */ @@ -928,22 +387,28 @@ AcpiUtInitGlobals ( /* Namespace */ + AcpiGbl_ModuleCodeList = NULL; AcpiGbl_RootNode = NULL; AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Parent = NULL; AcpiGbl_RootNodeStruct.Child = NULL; AcpiGbl_RootNodeStruct.Peer = NULL; AcpiGbl_RootNodeStruct.Object = NULL; - AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; +#ifdef ACPI_DISASSEMBLER + AcpiGbl_ExternalList = NULL; +#endif + #ifdef ACPI_DEBUG_OUTPUT AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); #endif #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiGbl_DisplayFinalMemStats = FALSE; + AcpiGbl_DisableMemTracking = FALSE; #endif return_ACPI_STATUS (AE_OK); @@ -956,5 +421,3 @@ ACPI_EXPORT_SYMBOL (AcpiDbgLevel) ACPI_EXPORT_SYMBOL (AcpiDbgLayer) ACPI_EXPORT_SYMBOL (AcpiGpeCount) ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) - - diff --git a/sys/contrib/dev/acpica-unix/utilities/utids.c b/sys/contrib/dev/acpica-unix/utilities/utids.c new file mode 100644 index 0000000000..0e43dabf27 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/utilities/utids.c @@ -0,0 +1,451 @@ +/****************************************************************************** + * + * Module Name: utids - support for device IDs - HID, UID, CID + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTIDS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utids") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. The HID is either an 32-bit encoded EISAID + * Integer or a String. A string is always returned. An EISAID + * is converted to a string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Hid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_HID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_EISAID_STRING_SIZE; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the HID */ + + Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Hid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID)); + + /* Convert EISAID to a string or simply copy existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value); + } + else + { + ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer); + } + + Hid->Length = Length; + *ReturnId = Hid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the unique + * ID of the device. The UID is either a 64-bit Integer (NOT an + * EISAID) or a string. Always returns a string. A 64-bit integer + * is converted to a decimal string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Uid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_UID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_MAX64_DECIMAL_DIGITS + 1; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the UID */ + + Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Uid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID)); + + /* Convert an Integer to string, or just copy an existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value); + } + else + { + ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer); + } + + Uid->Length = Length; + *ReturnId = Uid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_CID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnCidList - Where the CID list is returned + * + * RETURN: Status, list of CID strings + * + * DESCRIPTION: Executes the _CID control method that returns one or more + * compatible hardware IDs for the device. + * + * NOTE: Internal function, no parameter validation + * + * A _CID method can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") + * + * The Integer CIDs are converted to string format by this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList) +{ + ACPI_OPERAND_OBJECT **CidObjects; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID_LIST *CidList; + char *NextIdString; + UINT32 StringAreaSize; + UINT32 Length; + UINT32 CidListSize; + ACPI_STATUS Status; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecute_CID); + + + /* Evaluate the _CID method for this device */ + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Get the count and size of the returned _CIDs. _CID can return either + * a Package of Integers/Strings or a single Integer or String. + * Note: This section also validates that all CID elements are of the + * correct type (Integer or String). + */ + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Count = ObjDesc->Package.Count; + CidObjects = ObjDesc->Package.Elements; + } + else /* Single Integer or String CID */ + { + Count = 1; + CidObjects = &ObjDesc; + } + + StringAreaSize = 0; + for (i = 0; i < Count; i++) + { + /* String lengths include null terminator */ + + switch (CidObjects[i]->Common.Type) + { + case ACPI_TYPE_INTEGER: + StringAreaSize += ACPI_EISAID_STRING_SIZE; + break; + + case ACPI_TYPE_STRING: + StringAreaSize += CidObjects[i]->String.Length + 1; + break; + + default: + Status = AE_TYPE; + goto Cleanup; + } + } + + /* + * Now that we know the length of the CIDs, allocate return buffer: + * 1) Size of the base structure + + * 2) Size of the CID DEVICE_ID array + + * 3) Size of the actual CID strings + */ + CidListSize = sizeof (ACPI_DEVICE_ID_LIST) + + ((Count - 1) * sizeof (ACPI_DEVICE_ID)) + + StringAreaSize; + + CidList = ACPI_ALLOCATE_ZEROED (CidListSize); + if (!CidList) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for CID strings starts after the CID DEVICE_ID array */ + + NextIdString = ACPI_CAST_PTR (char, CidList->Ids) + + ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID)); + + /* Copy/convert the CIDs to the return buffer */ + + for (i = 0; i < Count; i++) + { + if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER) + { + /* Convert the Integer (EISAID) CID to a string */ + + AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value); + Length = ACPI_EISAID_STRING_SIZE; + } + else /* ACPI_TYPE_STRING */ + { + /* Copy the String CID from the returned object */ + + ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer); + Length = CidObjects[i]->String.Length + 1; + } + + CidList->Ids[i].String = NextIdString; + CidList->Ids[i].Length = Length; + NextIdString += Length; + } + + /* Finish the CID list */ + + CidList->Count = Count; + CidList->ListSize = CidListSize; + *ReturnCidList = CidList; + + +Cleanup: + + /* On exit, we must delete the _CID return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica-unix/utilities/utinit.c b/sys/contrib/dev/acpica-unix/utilities/utinit.c index 8e8a83b354..9e06711f47 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utinit.c +++ b/sys/contrib/dev/acpica-unix/utilities/utinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -184,12 +184,12 @@ AcpiUtTerminate ( * * FUNCTION: AcpiUtSubsystemShutdown * - * PARAMETERS: none + * PARAMETERS: None * - * RETURN: none + * RETURN: None * - * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex - * objects here -- because the AML debugger may be still running. + * DESCRIPTION: Shutdown the various components. Do not delete the mutex + * objects here, because the AML debugger may be still running. * ******************************************************************************/ @@ -197,30 +197,18 @@ void AcpiUtSubsystemShutdown ( void) { - ACPI_FUNCTION_TRACE (UtSubsystemShutdown); - /* Just exit if subsystem is already shutdown */ - - if (AcpiGbl_Shutdown) - { - ACPI_ERROR ((AE_INFO, - "ACPI Subsystem is already terminated")); - return_VOID; - } - - /* Subsystem appears active, go ahead and shut it down */ - - AcpiGbl_Shutdown = TRUE; - AcpiGbl_StartupFlags = 0; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Shutting down ACPI Subsystem\n")); #ifndef ACPI_ASL_COMPILER /* Close the AcpiEvent Handling */ AcpiEvTerminate (); + + /* Delete any dynamic _OSI interfaces */ + + AcpiUtInterfaceTerminate (); #endif /* Close the Namespace */ diff --git a/sys/contrib/dev/acpica-unix/utilities/utlock.c b/sys/contrib/dev/acpica-unix/utilities/utlock.c index dd4e100001..6e68ec0043 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utlock.c +++ b/sys/contrib/dev/acpica-unix/utilities/utlock.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/utilities/utmath.c b/sys/contrib/dev/acpica-unix/utilities/utmath.c index b0a40ff2bc..5c6d20e3c9 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utmath.c +++ b/sys/contrib/dev/acpica-unix/utilities/utmath.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -124,12 +124,32 @@ ACPI_MODULE_NAME ("utmath") /* - * Support for double-precision integer divide. This code is included here - * in order to support kernel environments where the double-precision math - * library is not available. + * Optional support for 64-bit double-precision integer divide. This code + * is configurable and is implemented in order to support 32-bit kernel + * environments where a 64-bit double-precision math library is not available. + * + * Support for a more normal 64-bit divide/modulo (with check for a divide- + * by-zero) appears after this optional section of code. */ - #ifndef ACPI_USE_NATIVE_DIVIDE + +/* Structures used only for 64-bit divide */ + +typedef struct uint64_struct +{ + UINT32 Lo; + UINT32 Hi; + +} UINT64_STRUCT; + +typedef union uint64_overlay +{ + UINT64 Full; + UINT64_STRUCT Part; + +} UINT64_OVERLAY; + + /******************************************************************************* * * FUNCTION: AcpiUtShortDivide @@ -149,9 +169,9 @@ ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER Dividend, + UINT64 Dividend, UINT32 Divisor, - ACPI_INTEGER *OutQuotient, + UINT64 *OutQuotient, UINT32 *OutRemainder) { UINT64_OVERLAY DividendOvl; @@ -213,10 +233,10 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER InDividend, - ACPI_INTEGER InDivisor, - ACPI_INTEGER *OutQuotient, - ACPI_INTEGER *OutRemainder) + UINT64 InDividend, + UINT64 InDivisor, + UINT64 *OutQuotient, + UINT64 *OutRemainder) { UINT64_OVERLAY Dividend; UINT64_OVERLAY Divisor; @@ -293,8 +313,8 @@ AcpiUtDivide ( * The 64-bit remainder must be generated. */ Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; - Partial2.Full = (ACPI_INTEGER) Quotient.Part.Lo * Divisor.Part.Lo; - Partial3.Full = (ACPI_INTEGER) Partial2.Part.Hi + Partial1; + Partial2.Full = (UINT64) Quotient.Part.Lo * Divisor.Part.Lo; + Partial3.Full = (UINT64) Partial2.Part.Hi + Partial1; Remainder.Part.Hi = Partial3.Part.Lo; Remainder.Part.Lo = Partial2.Part.Lo; @@ -362,9 +382,9 @@ AcpiUtDivide ( ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER InDividend, + UINT64 InDividend, UINT32 Divisor, - ACPI_INTEGER *OutQuotient, + UINT64 *OutQuotient, UINT32 *OutRemainder) { @@ -395,10 +415,10 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER InDividend, - ACPI_INTEGER InDivisor, - ACPI_INTEGER *OutQuotient, - ACPI_INTEGER *OutRemainder) + UINT64 InDividend, + UINT64 InDivisor, + UINT64 *OutQuotient, + UINT64 *OutRemainder) { ACPI_FUNCTION_TRACE (UtDivide); diff --git a/sys/contrib/dev/acpica-unix/utilities/utmisc.c b/sys/contrib/dev/acpica-unix/utilities/utmisc.c index 165b45ebf0..d379a220d3 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utmisc.c +++ b/sys/contrib/dev/acpica-unix/utilities/utmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -205,6 +205,40 @@ AcpiUtValidateException ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtIsPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root bridge. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRCMP (Id, + PCI_ROOT_HID_STRING)) || + + !(ACPI_STRCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING))) + { + return (TRUE); + } + + return (FALSE); +} + + /******************************************************************************* * * FUNCTION: AcpiUtIsAmlTable @@ -268,7 +302,7 @@ AcpiUtAllocateOwnerId ( if (*OwnerId) { - ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId)); + ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId)); return_ACPI_STATUS (AE_ALREADY_EXISTS); } @@ -387,7 +421,7 @@ AcpiUtReleaseOwnerId ( if (OwnerId == 0) { - ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId)); + ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId)); return_VOID; } @@ -417,7 +451,7 @@ AcpiUtReleaseOwnerId ( else { ACPI_ERROR ((AE_INFO, - "Release of non-allocated OwnerId: %2.2X", OwnerId + 1)); + "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1)); } (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); @@ -465,6 +499,48 @@ AcpiUtStrupr ( } +#ifdef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlwr (strlwr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to lowercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AcpiUtStrlwr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, lowercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOLOWER (*String); + } + + return; +} +#endif + + /******************************************************************************* * * FUNCTION: AcpiUtPrintString @@ -889,12 +965,12 @@ ACPI_STATUS AcpiUtStrtoul64 ( char *String, UINT32 Base, - ACPI_INTEGER *RetInteger) + UINT64 *RetInteger) { UINT32 ThisDigit = 0; - ACPI_INTEGER ReturnValue = 0; - ACPI_INTEGER Quotient; - ACPI_INTEGER Dividend; + UINT64 ReturnValue = 0; + UINT64 Quotient; + UINT64 Dividend; UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); UINT8 ValidDigits = 0; @@ -1031,7 +1107,7 @@ AcpiUtStrtoul64 ( /* Divide the digit into the correct position */ - (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), + (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit), Base, &Quotient, NULL); if (ReturnValue > Quotient) @@ -1255,96 +1331,3 @@ AcpiUtWalkPackageTree ( } -/******************************************************************************* - * - * FUNCTION: AcpiError, AcpiException, AcpiWarning, AcpiInfo - * - * PARAMETERS: ModuleName - Caller's module name (for error output) - * LineNumber - Caller's line number (for error output) - * Format - Printf format string + additional args - * - * RETURN: None - * - * DESCRIPTION: Print message with module/line/version info - * - ******************************************************************************/ - -void ACPI_INTERNAL_VAR_XFACE -AcpiError ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) -{ - va_list args; - - - AcpiOsPrintf ("ACPI Error: "); - - va_start (args, Format); - AcpiOsVprintf (Format, args); - AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber); - va_end (args); -} - -void ACPI_INTERNAL_VAR_XFACE -AcpiException ( - const char *ModuleName, - UINT32 LineNumber, - ACPI_STATUS Status, - const char *Format, - ...) -{ - va_list args; - - - AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status)); - - va_start (args, Format); - AcpiOsVprintf (Format, args); - AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber); - va_end (args); -} - -void ACPI_INTERNAL_VAR_XFACE -AcpiWarning ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) -{ - va_list args; - - - AcpiOsPrintf ("ACPI Warning: "); - - va_start (args, Format); - AcpiOsVprintf (Format, args); - AcpiOsPrintf (" %8.8X %s-%u\n", ACPI_CA_VERSION, ModuleName, LineNumber); - va_end (args); -} - -void ACPI_INTERNAL_VAR_XFACE -AcpiInfo ( - const char *ModuleName, - UINT32 LineNumber, - const char *Format, - ...) -{ - va_list args; - - - AcpiOsPrintf ("ACPI: "); - - va_start (args, Format); - AcpiOsVprintf (Format, args); - AcpiOsPrintf ("\n"); - va_end (args); -} - -ACPI_EXPORT_SYMBOL (AcpiError) -ACPI_EXPORT_SYMBOL (AcpiException) -ACPI_EXPORT_SYMBOL (AcpiWarning) -ACPI_EXPORT_SYMBOL (AcpiInfo) - - diff --git a/sys/contrib/dev/acpica-unix/utilities/utmutex.c b/sys/contrib/dev/acpica-unix/utilities/utmutex.c index f6e7cc3652..01a2422e93 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utmutex.c +++ b/sys/contrib/dev/acpica-unix/utilities/utmutex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -128,7 +128,7 @@ static ACPI_STATUS AcpiUtCreateMutex ( ACPI_MUTEX_HANDLE MutexId); -static ACPI_STATUS +static void AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE MutexId); @@ -182,6 +182,13 @@ AcpiUtMutexInitialize ( return_ACPI_STATUS (Status); } + /* Mutex for _OSI support */ + Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Create the reader/writer lock for namespace access */ Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); @@ -216,9 +223,11 @@ AcpiUtMutexTerminate ( for (i = 0; i < ACPI_NUM_MUTEX; i++) { - (void) AcpiUtDeleteMutex (i); + AcpiUtDeleteMutex (i); } + AcpiOsDeleteMutex (AcpiGbl_OsiMutex); + /* Delete the spinlocks */ AcpiOsDeleteLock (AcpiGbl_GpeLock); @@ -253,11 +262,6 @@ AcpiUtCreateMutex ( ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); - if (MutexId > ACPI_MAX_MUTEX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - if (!AcpiGbl_MutexInfo[MutexId].Mutex) { Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); @@ -281,7 +285,7 @@ AcpiUtCreateMutex ( * ******************************************************************************/ -static ACPI_STATUS +static void AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE MutexId) { @@ -289,17 +293,10 @@ AcpiUtDeleteMutex ( ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId); - if (MutexId > ACPI_MAX_MUTEX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex); AcpiGbl_MutexInfo[MutexId].Mutex = NULL; AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - - return_ACPI_STATUS (AE_OK); } @@ -351,16 +348,16 @@ AcpiUtAcquireMutex ( if (i == MutexId) { ACPI_ERROR ((AE_INFO, - "Mutex [%s] already acquired by this thread [%p]", + "Mutex [%s] already acquired by this thread [%u]", AcpiUtGetMutexName (MutexId), - ACPI_CAST_PTR (void, ThisThreadId))); + (UINT32) ThisThreadId)); return (AE_ALREADY_ACQUIRED); } ACPI_ERROR ((AE_INFO, - "Invalid acquire order: Thread %p owns [%s], wants [%s]", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i), + "Invalid acquire order: Thread %u owns [%s], wants [%s]", + (UINT32) ThisThreadId, AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); return (AE_ACQUIRE_DEADLOCK); @@ -370,15 +367,15 @@ AcpiUtAcquireMutex ( #endif ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %p attempting to acquire Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + "Thread %u attempting to acquire Mutex [%s]\n", + (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId))); Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u acquired Mutex [%s]\n", + (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId))); AcpiGbl_MutexInfo[MutexId].UseCount++; AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; @@ -386,8 +383,8 @@ AcpiUtAcquireMutex ( else { ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %p could not acquire Mutex [%X]", - ACPI_CAST_PTR (void, ThisThreadId), MutexId)); + "Thread %u could not acquire Mutex [0x%X]", + (UINT32) ThisThreadId, MutexId)); } return (Status); @@ -417,8 +414,8 @@ AcpiUtReleaseMutex ( ThisThreadId = AcpiOsGetThreadId (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", - ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n", + (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId))); if (MutexId > ACPI_MAX_MUTEX) { @@ -431,7 +428,7 @@ AcpiUtReleaseMutex ( if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) { ACPI_ERROR ((AE_INFO, - "Mutex [%X] is not acquired, cannot release", MutexId)); + "Mutex [0x%X] is not acquired, cannot release", MutexId)); return (AE_NOT_ACQUIRED); } diff --git a/sys/contrib/dev/acpica-unix/utilities/utobject.c b/sys/contrib/dev/acpica-unix/utilities/utobject.c index 2cd351909e..f62ebe01a8 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utobject.c +++ b/sys/contrib/dev/acpica-unix/utilities/utobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -279,6 +279,41 @@ AcpiUtCreatePackageObject ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateIntegerObject + * + * PARAMETERS: InitialValue - Initial value for the integer + * + * RETURN: Pointer to a new Integer object, null on failure + * + * DESCRIPTION: Create an initialized integer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 InitialValue) +{ + ACPI_OPERAND_OBJECT *IntegerDesc; + + + ACPI_FUNCTION_TRACE (UtCreateIntegerObject); + + + /* Create and initialize a new integer object */ + + IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!IntegerDesc) + { + return_PTR (NULL); + } + + IntegerDesc->Integer.Value = InitialValue; + return_PTR (IntegerDesc); +} + + /******************************************************************************* * * FUNCTION: AcpiUtCreateBufferObject @@ -319,7 +354,7 @@ AcpiUtCreateBufferObject ( Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); if (!Buffer) { - ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + ACPI_ERROR ((AE_INFO, "Could not allocate size %u", (UINT32) BufferSize)); AcpiUtRemoveReference (BufferDesc); return_PTR (NULL); @@ -378,7 +413,7 @@ AcpiUtCreateStringObject ( String = ACPI_ALLOCATE_ZEROED (StringSize + 1); if (!String) { - ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + ACPI_ERROR ((AE_INFO, "Could not allocate size %u", (UINT32) StringSize)); AcpiUtRemoveReference (StringDesc); return_PTR (NULL); @@ -520,7 +555,7 @@ AcpiUtDeleteObjectDesc ( return_VOID; } - ACPI_OS_RELEASE_OBJECT(AcpiGbl_OperandCache, Object); + (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); return_VOID; } @@ -636,7 +671,7 @@ AcpiUtGetSimpleObjectSize ( * required eventually. */ ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " - "unsupported Reference Class [%s] %X in object %p", + "unsupported Reference Class [%s] 0x%X in object %p", AcpiUtGetReferenceName (InternalObject), InternalObject->Reference.Class, InternalObject)); Status = AE_TYPE; @@ -648,7 +683,7 @@ AcpiUtGetSimpleObjectSize ( default: ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " - "unsupported type [%s] %X in object %p", + "unsupported type [%s] 0x%X in object %p", AcpiUtGetObjectTypeName (InternalObject), InternalObject->Common.Type, InternalObject)); Status = AE_TYPE; diff --git a/sys/contrib/dev/acpica-unix/utilities/utosi.c b/sys/contrib/dev/acpica-unix/utilities/utosi.c new file mode 100644 index 0000000000..2b64d674b2 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/utilities/utosi.c @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Module Name: utosi - Support for the _OSI predefined control method + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTOSI_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utosi") + +/* + * Strings supported by the _OSI predefined control method (which is + * implemented internally within this module.) + * + * March 2009: Removed "Linux" as this host no longer wants to respond true + * for this string. Basically, the only safe OS strings are windows-related + * and in many or most cases represent the only test path within the + * BIOS-provided ASL code. + * + * The last element of each entry is used to track the newest version of + * Windows that the BIOS has requested. + */ +static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] = +{ + /* Operating System Vendor Strings */ + + {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */ + {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */ + {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ + {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ + {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ + {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ + {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ + {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ + {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ + {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ + {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ + + /* Feature Group Strings */ + + {"Extended Address Space Descriptor", NULL, 0, 0} + + /* + * All "optional" feature group strings (features that are implemented + * by the host) should be dynamically added by the host via + * AcpiInstallInterface and should not be manually added here. + * + * Examples of optional feature group strings: + * + * "Module Device" + * "Processor Device" + * "3.0 Thermal Model" + * "3.0 _SCP Extensions" + * "Processor Aggregator Device" + */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitializeInterfaces + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the global _OSI supported interfaces list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitializeInterfaces ( + void) +{ + UINT32 i; + + + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces; + + /* Link the static list of supported interfaces */ + + for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++) + { + AcpiDefaultSupportedInterfaces[i].Next = + &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1]; + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInterfaceTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all interfaces in the global list. Sets + * AcpiGbl_SupportedInterfaces to NULL. + * + ******************************************************************************/ + +void +AcpiUtInterfaceTerminate ( + void) +{ + ACPI_INTERFACE_INFO *NextInterface; + + + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + NextInterface = AcpiGbl_SupportedInterfaces; + + while (NextInterface) + { + AcpiGbl_SupportedInterfaces = NextInterface->Next; + + /* Only interfaces added at runtime can be freed */ + + if (NextInterface->Flags & ACPI_OSI_DYNAMIC) + { + ACPI_FREE (NextInterface->Name); + ACPI_FREE (NextInterface); + } + + NextInterface = AcpiGbl_SupportedInterfaces; + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInstallInterface + * + * PARAMETERS: InterfaceName - The interface to install + * + * RETURN: Status + * + * DESCRIPTION: Install the interface into the global interface list. + * Caller MUST hold AcpiGbl_OsiMutex + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInstallInterface ( + ACPI_STRING InterfaceName) +{ + ACPI_INTERFACE_INFO *InterfaceInfo; + + + /* Allocate info block and space for the name string */ + + InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO)); + if (!InterfaceInfo) + { + return (AE_NO_MEMORY); + } + + InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1); + if (!InterfaceInfo->Name) + { + ACPI_FREE (InterfaceInfo); + return (AE_NO_MEMORY); + } + + /* Initialize new info and insert at the head of the global list */ + + ACPI_STRCPY (InterfaceInfo->Name, InterfaceName); + InterfaceInfo->Flags = ACPI_OSI_DYNAMIC; + InterfaceInfo->Next = AcpiGbl_SupportedInterfaces; + + AcpiGbl_SupportedInterfaces = InterfaceInfo; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveInterface + * + * PARAMETERS: InterfaceName - The interface to remove + * + * RETURN: Status + * + * DESCRIPTION: Remove the interface from the global interface list. + * Caller MUST hold AcpiGbl_OsiMutex + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtRemoveInterface ( + ACPI_STRING InterfaceName) +{ + ACPI_INTERFACE_INFO *PreviousInterface; + ACPI_INTERFACE_INFO *NextInterface; + + + PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces; + while (NextInterface) + { + if (!ACPI_STRCMP (InterfaceName, NextInterface->Name)) + { + /* Found: name is in either the static list or was added at runtime */ + + if (NextInterface->Flags & ACPI_OSI_DYNAMIC) + { + /* Interface was added dynamically, remove and free it */ + + if (PreviousInterface == NextInterface) + { + AcpiGbl_SupportedInterfaces = NextInterface->Next; + } + else + { + PreviousInterface->Next = NextInterface->Next; + } + + ACPI_FREE (NextInterface->Name); + ACPI_FREE (NextInterface); + } + else + { + /* + * Interface is in static list. If marked invalid, then it + * does not actually exist. Else, mark it invalid. + */ + if (NextInterface->Flags & ACPI_OSI_INVALID) + { + return (AE_NOT_EXIST); + } + + NextInterface->Flags |= ACPI_OSI_INVALID; + } + + return (AE_OK); + } + + PreviousInterface = NextInterface; + NextInterface = NextInterface->Next; + } + + /* Interface was not found */ + + return (AE_NOT_EXIST); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetInterface + * + * PARAMETERS: InterfaceName - The interface to find + * + * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found. + * + * DESCRIPTION: Search for the specified interface name in the global list. + * Caller MUST hold AcpiGbl_OsiMutex + * + ******************************************************************************/ + +ACPI_INTERFACE_INFO * +AcpiUtGetInterface ( + ACPI_STRING InterfaceName) +{ + ACPI_INTERFACE_INFO *NextInterface; + + + NextInterface = AcpiGbl_SupportedInterfaces; + while (NextInterface) + { + if (!ACPI_STRCMP (InterfaceName, NextInterface->Name)) + { + return (NextInterface); + } + + NextInterface = NextInterface->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtOsiImplementation + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Implementation of the _OSI predefined control method. When + * an invocation of _OSI is encountered in the system AML, + * control is transferred to this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *StringDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_INTERFACE_INFO *InterfaceInfo; + ACPI_INTERFACE_HANDLER InterfaceHandler; + UINT32 ReturnValue; + + + ACPI_FUNCTION_TRACE (UtOsiImplementation); + + + /* Validate the string input argument (from the AML caller) */ + + StringDesc = WalkState->Arguments[0].Object; + if (!StringDesc || + (StringDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* Create a return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Default return value is 0, NOT SUPPORTED */ + + ReturnValue = 0; + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + + /* Lookup the interface in the global _OSI list */ + + InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer); + if (InterfaceInfo && + !(InterfaceInfo->Flags & ACPI_OSI_INVALID)) + { + /* + * The interface is supported. + * Update the OsiData if necessary. We keep track of the latest + * version of Windows that has been requested by the BIOS. + */ + if (InterfaceInfo->Value > AcpiGbl_OsiData) + { + AcpiGbl_OsiData = InterfaceInfo->Value; + } + + ReturnValue = ACPI_UINT32_MAX; + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + + /* + * Invoke an optional _OSI interface handler. The host OS may wish + * to do some interface-specific handling. For example, warn about + * certain interfaces or override the true/false support value. + */ + InterfaceHandler = AcpiGbl_InterfaceHandler; + if (InterfaceHandler) + { + ReturnValue = InterfaceHandler ( + StringDesc->String.Pointer, ReturnValue); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, + "ACPI: BIOS _OSI(\"%s\") is %ssupported\n", + StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); + + /* Complete the return object */ + + ReturnDesc->Integer.Value = ReturnValue; + WalkState->ReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} diff --git a/sys/contrib/dev/acpica-unix/utilities/utresrc.c b/sys/contrib/dev/acpica-unix/utilities/utresrc.c index 2f19d63986..a6b6d9c810 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utresrc.c +++ b/sys/contrib/dev/acpica-unix/utilities/utresrc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica-unix/utilities/utstate.c b/sys/contrib/dev/acpica-unix/utilities/utstate.c index 6dbef0b493..c23c701787 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utstate.c +++ b/sys/contrib/dev/acpica-unix/utilities/utstate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -462,7 +462,7 @@ AcpiUtDeleteGenericState ( if (State) { - ACPI_OS_RELEASE_OBJECT(AcpiGbl_StateCache, State); + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); } return_VOID; } diff --git a/sys/contrib/dev/acpica-unix/utilities/uttrack.c b/sys/contrib/dev/acpica-unix/utilities/uttrack.c index d712c1a3e5..f5599b792f 100644 --- a/sys/contrib/dev/acpica-unix/utilities/uttrack.c +++ b/sys/contrib/dev/acpica-unix/utilities/uttrack.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -282,7 +282,7 @@ AcpiUtAllocateZeroedAndTrack ( /* Report allocation error */ ACPI_ERROR ((Module, Line, - "Could not allocate size %X", (UINT32) Size)); + "Could not allocate size %u", (UINT32) Size)); return (NULL); } @@ -436,6 +436,11 @@ AcpiUtTrackAllocation ( ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); + if (AcpiGbl_DisableMemTracking) + { + return_ACPI_STATUS (AE_OK); + } + MemList = AcpiGbl_GlobalList; Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (Status)) @@ -518,6 +523,11 @@ AcpiUtRemoveAllocation ( ACPI_FUNCTION_TRACE (UtRemoveAllocation); + if (AcpiGbl_DisableMemTracking) + { + return_ACPI_STATUS (AE_OK); + } + MemList = AcpiGbl_GlobalList; if (NULL == MemList->ListHead) { @@ -644,11 +654,17 @@ AcpiUtDumpAllocations ( ACPI_DEBUG_MEM_BLOCK *Element; ACPI_DESCRIPTOR *Descriptor; UINT32 NumOutstanding = 0; + UINT8 DescriptorType; ACPI_FUNCTION_TRACE (UtDumpAllocations); + if (AcpiGbl_DisableMemTracking) + { + return; + } + /* * Walk the allocation list. */ @@ -663,43 +679,86 @@ AcpiUtDumpAllocations ( if ((Element->Component & Component) && ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) { - /* Ignore allocated objects that are in a cache */ - Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); - if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + + if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR)) { - AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u " + "[Not a Descriptor - too small]\n", Descriptor, Element->Size, Element->Module, - Element->Line, AcpiUtGetDescriptorName (Descriptor)); - - /* Most of the elements will be Operand objects. */ + Element->Line); + } + else + { + /* Ignore allocated objects that are in a cache */ - switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) { - case ACPI_DESC_TYPE_OPERAND: - AcpiOsPrintf ("%12.12s R%hd", - AcpiUtGetTypeName (Descriptor->Object.Common.Type), - Descriptor->Object.Common.ReferenceCount); - break; - - case ACPI_DESC_TYPE_PARSER: - AcpiOsPrintf ("AmlOpcode %04hX", - Descriptor->Op.Asl.AmlOpcode); - break; - - case ACPI_DESC_TYPE_NAMED: - AcpiOsPrintf ("%4.4s", - AcpiUtGetNodeName (&Descriptor->Node)); - break; - - default: - break; + AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Validate the descriptor type using Type field and length */ + + DescriptorType = 0; /* Not a valid descriptor type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + case ACPI_DESC_TYPE_OPERAND: + if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND)) + { + DescriptorType = ACPI_DESC_TYPE_OPERAND; + } + break; + + case ACPI_DESC_TYPE_PARSER: + if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER)) + { + DescriptorType = ACPI_DESC_TYPE_PARSER; + } + break; + + case ACPI_DESC_TYPE_NAMED: + if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED)) + { + DescriptorType = ACPI_DESC_TYPE_NAMED; + } + break; + + default: + break; + } + + /* Display additional info for the major descriptor types */ + + switch (DescriptorType) + { + case ACPI_DESC_TYPE_OPERAND: + AcpiOsPrintf ("%12.12s RefCount 0x%04X\n", + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); + break; + + case ACPI_DESC_TYPE_PARSER: + AcpiOsPrintf ("AmlOpcode 0x%04hX\n", + Descriptor->Op.Asl.AmlOpcode); + break; + + case ACPI_DESC_TYPE_NAMED: + AcpiOsPrintf ("%4.4s\n", + AcpiUtGetNodeName (&Descriptor->Node)); + break; + + default: + AcpiOsPrintf ( "\n"); + break; + } } - - AcpiOsPrintf ( "\n"); - NumOutstanding++; } + + NumOutstanding++; } + Element = Element->Next; } @@ -709,13 +768,11 @@ AcpiUtDumpAllocations ( if (!NumOutstanding) { - ACPI_INFO ((AE_INFO, - "No outstanding allocations")); + ACPI_INFO ((AE_INFO, "No outstanding allocations")); } else { - ACPI_ERROR ((AE_INFO, - "%d(%X) Outstanding allocations", + ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations", NumOutstanding, NumOutstanding)); } diff --git a/sys/contrib/dev/acpica-unix/utilities/utxface.c b/sys/contrib/dev/acpica-unix/utilities/utxface.c index 4207f3d598..d65c8210e1 100644 --- a/sys/contrib/dev/acpica-unix/utilities/utxface.c +++ b/sys/contrib/dev/acpica-unix/utilities/utxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. * All rights reserved. * * 2. License @@ -193,6 +193,15 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } + /* Initialize the global OSI interfaces list with the static names */ + + Status = AcpiUtInitializeInterfaces (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization")); + return_ACPI_STATUS (Status); + } + /* If configured, initialize the AML debugger */ ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); @@ -359,6 +368,16 @@ AcpiInitializeObjects ( } } + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + */ + AcpiNsExecModuleCodeList (); + /* * Initialize the objects that remain uninitialized. This runs the * executable AML that may be part of the declaration of these objects: @@ -392,27 +411,6 @@ AcpiInitializeObjects ( } } - /* - * Initialize the GPE blocks defined in the FADT (GPE block 0 and 1). - * The runtime GPEs are enabled here. - * - * This is where the _PRW methods are executed for the GPEs. These - * methods can only be executed after the SCI and Global Lock handlers are - * installed and initialized. - * - * GPEs can only be enabled after the _REG, _STA, and _INI methods have - * been run. This ensures that all Operation Regions and all Devices have - * been initialized and are ready. - */ - if (!(Flags & ACPI_NO_EVENT_INIT)) - { - Status = AcpiEvInstallFadtGpes (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - /* * Empty the caches (delete the cached objects) on the assumption that * the table load filled them up more than they will be at runtime -- @@ -437,7 +435,7 @@ ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) * * RETURN: Status * - * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. + * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. * ******************************************************************************/ @@ -451,15 +449,28 @@ AcpiTerminate ( ACPI_FUNCTION_TRACE (AcpiTerminate); + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + /* Terminate the AML Debugger if present */ - ACPI_DEBUGGER_EXEC(AcpiGbl_DbTerminateThreads = TRUE); + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); /* Shutdown and free all resources */ AcpiUtSubsystemShutdown (); - /* Free the mutex objects */ AcpiUtMutexTerminate (); @@ -480,8 +491,8 @@ AcpiTerminate ( ACPI_EXPORT_SYMBOL (AcpiTerminate) -#ifndef ACPI_ASL_COMPILER +#ifndef ACPI_ASL_COMPILER /******************************************************************************* * * FUNCTION: AcpiSubsystemStatus @@ -707,5 +718,144 @@ AcpiPurgeCachedObjects ( ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) -#endif /* ACPI_ASL_COMPILER */ + +/***************************************************************************** + * + * FUNCTION: AcpiInstallInterface + * + * PARAMETERS: InterfaceName - The interface to install + * + * RETURN: Status + * + * DESCRIPTION: Install an _OSI interface to the global list + * + ****************************************************************************/ + +ACPI_STATUS +AcpiInstallInterface ( + ACPI_STRING InterfaceName) +{ + ACPI_STATUS Status; + ACPI_INTERFACE_INFO *InterfaceInfo; + + + /* Parameter validation */ + + if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0)) + { + return (AE_BAD_PARAMETER); + } + + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + + /* Check if the interface name is already in the global list */ + + InterfaceInfo = AcpiUtGetInterface (InterfaceName); + if (InterfaceInfo) + { + /* + * The interface already exists in the list. This is OK if the + * interface has been marked invalid -- just clear the bit. + */ + if (InterfaceInfo->Flags & ACPI_OSI_INVALID) + { + InterfaceInfo->Flags &= ~ACPI_OSI_INVALID; + Status = AE_OK; + } + else + { + Status = AE_ALREADY_EXISTS; + } + } + else + { + /* New interface name, install into the global list */ + + Status = AcpiUtInstallInterface (InterfaceName); + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallInterface) + + +/***************************************************************************** + * + * FUNCTION: AcpiRemoveInterface + * + * PARAMETERS: InterfaceName - The interface to remove + * + * RETURN: Status + * + * DESCRIPTION: Remove an _OSI interface from the global list + * + ****************************************************************************/ + +ACPI_STATUS +AcpiRemoveInterface ( + ACPI_STRING InterfaceName) +{ + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0)) + { + return (AE_BAD_PARAMETER); + } + + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + + Status = AcpiUtRemoveInterface (InterfaceName); + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveInterface) + + +/***************************************************************************** + * + * FUNCTION: AcpiInstallInterfaceHandler + * + * PARAMETERS: Handler - The _OSI interface handler to install + * NULL means "remove existing handler" + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the predefined _OSI ACPI method. + * invoked during execution of the internal implementation of + * _OSI. A NULL handler simply removes any existing handler. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiInstallInterfaceHandler ( + ACPI_INTERFACE_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + + if (Handler && AcpiGbl_InterfaceHandler) + { + Status = AE_ALREADY_EXISTS; + } + else + { + AcpiGbl_InterfaceHandler = Handler; + } + + AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler) + +#endif /* !ACPI_ASL_COMPILER */ diff --git a/sys/contrib/dev/acpica-unix/utilities/utxferror.c b/sys/contrib/dev/acpica-unix/utilities/utxferror.c new file mode 100644 index 0000000000..60e6217135 --- /dev/null +++ b/sys/contrib/dev/acpica-unix/utilities/utxferror.c @@ -0,0 +1,550 @@ +/******************************************************************************* + * + * Module Name: utxferror - Various error/warning output functions + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTXFERROR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utxferror") + +/* + * This module is used for the in-kernel ACPICA as well as the ACPICA + * tools/applications. + * + * For the iASL compiler case, the output is redirected to stderr so that + * any of the various ACPI errors and warnings do not appear in the output + * files, for either the compiler or disassembler portions of the tool. + */ +#ifdef ACPI_ASL_COMPILER +#include + +extern FILE *AcpiGbl_OutputFile; + +#define ACPI_MSG_REDIRECT_BEGIN \ + FILE *OutputFile = AcpiGbl_OutputFile; \ + AcpiOsRedirectOutput (stderr); + +#define ACPI_MSG_REDIRECT_END \ + AcpiOsRedirectOutput (OutputFile); + +#else +/* + * non-iASL case - no redirection, nothing to do + */ +#define ACPI_MSG_REDIRECT_BEGIN +#define ACPI_MSG_REDIRECT_END +#endif + +/* + * Common message prefixes + */ +#define ACPI_MSG_ERROR "ACPI Error: " +#define ACPI_MSG_EXCEPTION "ACPI Exception: " +#define ACPI_MSG_WARNING "ACPI Warning: " +#define ACPI_MSG_INFO "ACPI: " + +/* + * Common message suffix + */ +#define ACPI_MSG_SUFFIX \ + AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) + + +/******************************************************************************* + * + * FUNCTION: AcpiError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print "ACPI Error" message with module/line/version info + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list ArgList; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_ERROR); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + ACPI_MSG_SUFFIX; + va_end (ArgList); + + ACPI_MSG_REDIRECT_END; +} + +ACPI_EXPORT_SYMBOL (AcpiError) + + +/******************************************************************************* + * + * FUNCTION: AcpiException + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Status - Status to be formatted + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print "ACPI Exception" message with module/line/version info + * and decoded ACPI_STATUS. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) +{ + va_list ArgList; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status)); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + ACPI_MSG_SUFFIX; + va_end (ArgList); + + ACPI_MSG_REDIRECT_END; +} + +ACPI_EXPORT_SYMBOL (AcpiException) + + +/******************************************************************************* + * + * FUNCTION: AcpiWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print "ACPI Warning" message with module/line/version info + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list ArgList; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_WARNING); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + ACPI_MSG_SUFFIX; + va_end (ArgList); + + ACPI_MSG_REDIRECT_END; +} + +ACPI_EXPORT_SYMBOL (AcpiWarning) + + +/******************************************************************************* + * + * FUNCTION: AcpiInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print generic "ACPI:" information message. There is no + * module/line/version info in order to keep the message simple. + * + * TBD: ModuleName and LineNumber args are not needed, should be removed. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list ArgList; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_INFO); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + AcpiOsPrintf ("\n"); + va_end (ArgList); + + ACPI_MSG_REDIRECT_END; +} + +ACPI_EXPORT_SYMBOL (AcpiInfo) + + +/* + * The remainder of this module contains internal error functions that may + * be configured out. + */ +#if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP) + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Warnings for the predefined validation module. Messages are + * only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of error + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list ArgList; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + ACPI_MSG_SUFFIX; + va_end (ArgList); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Info messages for the predefined validation module. Messages + * are only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list ArgList; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname); + + va_start (ArgList, Format); + AcpiOsVprintf (Format, ArgList); + ACPI_MSG_SUFFIX; + va_end (ArgList); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtNamespaceError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * InternalName - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup + * + * RETURN: None + * + * DESCRIPTION: Print error message with the full pathname for the NS node. + * + ******************************************************************************/ + +void +AcpiUtNamespaceError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus) +{ + ACPI_STATUS Status; + UINT32 BadName; + char *Name = NULL; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_ERROR); + + if (LookupStatus == AE_BAD_CHARACTER) + { + /* There is a non-ascii character in the name */ + + ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName)); + AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName); + } + else + { + /* Convert path to external format */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, + InternalName, NULL, &Name); + + /* Print target name */ + + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s]", Name); + } + else + { + AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); + } + + if (Name) + { + ACPI_FREE (Name); + } + } + + AcpiOsPrintf (" Namespace lookup failure, %s", + AcpiFormatException (LookupStatus)); + + ACPI_MSG_SUFFIX; + ACPI_MSG_REDIRECT_END; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMethodError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Message - Error message to use on failure + * PrefixNode - Prefix relative to the path + * Path - Path to the node (optional) + * MethodStatus - Execution status + * + * RETURN: None + * + * DESCRIPTION: Print error message with the full pathname for the method. + * + ******************************************************************************/ + +void +AcpiUtMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Path, + ACPI_STATUS MethodStatus) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = PrefixNode; + + + ACPI_MSG_REDIRECT_BEGIN; + AcpiOsPrintf (ACPI_MSG_ERROR); + + if (Path) + { + Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, + &Node); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("[Could not get node by pathname]"); + } + } + + AcpiNsPrintNodePathname (Node, Message); + AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus)); + + ACPI_MSG_SUFFIX; + ACPI_MSG_REDIRECT_END; +} + +#endif /* ACPI_NO_ERROR_MESSAGES */ diff --git a/sys/dev/acpica5/Makefile b/sys/dev/acpica5/Makefile index e582e4b88d..6238cab0d3 100644 --- a/sys/dev/acpica5/Makefile +++ b/sys/dev/acpica5/Makefile @@ -33,19 +33,21 @@ KMOD = acpi # ACPI CA sources SRCS+= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c SRCS+= dbinput.c dbstats.c dbutils.c dbxface.c +SRCS+= dbmethod.c dbnames.c SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c dmresrcl.c SRCS+= dmresrcs.c dmutils.c dmwalk.c SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c SRCS+= dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c -SRCS+= dswscope.c dswstate.c evevent.c evgpe.c evgpeblk.c +SRCS+= dswscope.c dswstate.c dsargs.c dscontrol.c dswload2.c +SRCS+= evevent.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c evxfgpe.c SRCS+= evmisc.c evregion.c evrgnini.c evsci.c evxface.c SRCS+= evxfevnt.c evxfregn.c exconfig.c exconvrt.c excreate.c SRCS+= exdump.c exfield.c exfldio.c exmisc.c exmutex.c SRCS+= exnames.c exoparg1.c exoparg2.c exoparg3.c exoparg6.c SRCS+= exprep.c exregion.c exresnte.c exresolv.c exresop.c -SRCS+= exstore.c exstoren.c exstorob.c exsystem.c exutils.c -SRCS+= hwacpi.c hwgpe.c hwregs.c hwsleep.c hwtimer.c hwvalid.c hwxface.c -SRCS+= nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c +SRCS+= exstore.c exstoren.c exstorob.c exsystem.c exutils.c exdebug.c +SRCS+= hwacpi.c hwgpe.c hwregs.c hwsleep.c hwtimer.c hwvalid.c hwxface.c hwpci.c +SRCS+= nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c nsrepair.c nsrepair2.c SRCS+= nsload.c nsnames.c nsobject.c nsparse.c nssearch.c nspredef.c SRCS+= nsutils.c nswalk.c nsxfeval.c nsxfname.c nsxfobj.c SRCS+= psargs.c psloop.c psopcode.c psparse.c psscope.c @@ -56,7 +58,7 @@ SRCS+= rsxface.c tbfadt.c tbfind.c tbinstal.c SRCS+= tbutils.c tbxface.c tbxfroot.c utalloc.c SRCS+= utclib.c utcopy.c utdebug.c utdelete.c uteval.c utlock.c SRCS+= utglobal.c utinit.c utmath.c utmisc.c utmutex.c utobject.c -SRCS+= utresrc.c utstate.c utxface.c +SRCS+= utresrc.c utstate.c utxface.c utdecode.c utids.c utosi.c utxferror.c # OSD layer # diff --git a/sys/dev/acpica5/Osd/OsdHardware.c b/sys/dev/acpica5/Osd/OsdHardware.c index 7062ba584a..d727c40943 100644 --- a/sys/dev/acpica5/Osd/OsdHardware.c +++ b/sys/dev/acpica5/Osd/OsdHardware.c @@ -108,7 +108,7 @@ AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, UINT32 Value, UINT32 Width) } ACPI_STATUS -AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, void *Value, +AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 *Value, UINT32 Width) { u_int32_t byte_width = Width / 8; @@ -127,8 +127,10 @@ AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, void *Value, *(u_int16_t *)Value = val & 0xffff; break; case 32: - *(u_int32_t *)Value = val; + *(u_int32_t *)Value = val & 0xffffffff; break; + case 64: + *(u_int64_t *)Value = val; default: /* debug trap goes here */ break; @@ -140,7 +142,7 @@ AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, void *Value, ACPI_STATUS AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, - ACPI_INTEGER Value, UINT32 Width) + UINT64 Value, UINT32 Width) { u_int32_t byte_width = Width / 8; @@ -148,7 +150,7 @@ AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, return (AE_NOT_EXIST); pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register, - Value, byte_width); + (u_int32_t) Value, byte_width); /* XXX casting */ return (AE_OK); } @@ -213,43 +215,3 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId) bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1); return (bus); } - -/* - * Find the bus number for a device - * - * rhandle: handle for the root bus - * chandle: handle for the device - * PciId: pointer to device slot and function, we fill out bus - */ -void -AcpiOsDerivePciId(ACPI_HANDLE rhandle, ACPI_HANDLE chandle, ACPI_PCI_ID **PciId) -{ - ACPI_HANDLE parent; - ACPI_STATUS status; - int bus; - - if (pci_cfgregopen() == 0) - panic("AcpiOsDerivePciId unable to initialize pci bus"); - - /* Try to read _BBN for bus number if we're at the root */ - bus = 0; - if (rhandle == chandle) { - status = acpi_GetInteger(rhandle, "_BBN", &bus); - if (ACPI_FAILURE(status) && bootverbose) - kprintf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n"); - } - - /* - * Get the parent handle and call the recursive case. It is not - * clear why we seem to be getting a chandle that points to a child - * of the desired slot/function but passing in the parent handle - * here works. - */ - if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent))) - bus = acpi_bus_number(rhandle, parent, *PciId); - (*PciId)->Bus = bus; - if (bootverbose) { - kprintf("AcpiOsDerivePciId: bus %d dev %d func %d\n", - (*PciId)->Bus, (*PciId)->Device, (*PciId)->Function); - } -} diff --git a/sys/dev/acpica5/acpi.c b/sys/dev/acpica5/acpi.c index b7486fea96..2f5530e422 100644 --- a/sys/dev/acpica5/acpi.c +++ b/sys/dev/acpica5/acpi.c @@ -842,25 +842,23 @@ static int acpi_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, size_t buflen) { - ACPI_BUFFER adbuf = {ACPI_ALLOCATE_BUFFER, NULL}; ACPI_DEVICE_INFO *adinfo; struct acpi_device *dinfo = device_get_ivars(child); char *end; int error; - error = AcpiGetObjectInfo(dinfo->ad_handle, &adbuf); - adinfo = (ACPI_DEVICE_INFO *) adbuf.Pointer; + error = AcpiGetObjectInfo(dinfo->ad_handle, &adinfo); if (error) ksnprintf(buf, buflen, "unknown"); - else + else { ksnprintf(buf, buflen, "_HID=%s _UID=%lu", (adinfo->Valid & ACPI_VALID_HID) ? - adinfo->HardwareId.Value : "none", + adinfo->HardwareId.String : "none", (adinfo->Valid & ACPI_VALID_UID) ? - strtoul(adinfo->UniqueId.Value, &end, 10) : 0); + strtoul(adinfo->UniqueId.String, &end, 10) : 0); if (adinfo) AcpiOsFree(adinfo); - + } return (0); } @@ -1197,7 +1195,6 @@ static uint32_t acpi_isa_get_logicalid(device_t dev) { ACPI_DEVICE_INFO *devinfo; - ACPI_BUFFER buf; ACPI_HANDLE h; ACPI_STATUS error; u_int32_t pnpid; @@ -1205,23 +1202,20 @@ acpi_isa_get_logicalid(device_t dev) ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); pnpid = 0; - buf.Pointer = NULL; - buf.Length = ACPI_ALLOCATE_BUFFER; /* Fetch and validate the HID. */ if ((h = acpi_get_handle(dev)) == NULL) goto out; - error = AcpiGetObjectInfo(h, &buf); + error = AcpiGetObjectInfo(h, &devinfo); if (ACPI_FAILURE(error)) goto out; - devinfo = (ACPI_DEVICE_INFO *)buf.Pointer; if ((devinfo->Valid & ACPI_VALID_HID) != 0) - pnpid = PNP_EISAID(devinfo->HardwareId.Value); + pnpid = PNP_EISAID(devinfo->HardwareId.String); out: - if (buf.Pointer != NULL) - AcpiOsFree(buf.Pointer); + if (devinfo) + AcpiOsFree(devinfo); return_VALUE (pnpid); } @@ -1229,7 +1223,6 @@ static int acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count) { ACPI_DEVICE_INFO *devinfo; - ACPI_BUFFER buf; ACPI_HANDLE h; ACPI_STATUS error; uint32_t *pnpid; @@ -1239,31 +1232,28 @@ acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count) pnpid = cids; valid = 0; - buf.Pointer = NULL; - buf.Length = ACPI_ALLOCATE_BUFFER; /* Fetch and validate the CID */ if ((h = acpi_get_handle(dev)) == NULL) goto out; - error = AcpiGetObjectInfo(h, &buf); + error = AcpiGetObjectInfo(h, &devinfo); if (ACPI_FAILURE(error)) goto out; - devinfo = (ACPI_DEVICE_INFO *)buf.Pointer; if ((devinfo->Valid & ACPI_VALID_CID) == 0) goto out; - if (devinfo->CompatibilityId.Count < count) - count = devinfo->CompatibilityId.Count; + if (devinfo->CompatibleIdList.Count < count) + count = devinfo->CompatibleIdList.Count; for (i = 0; i < count; i++) { - if (strncmp(devinfo->CompatibilityId.Id[i].Value, "PNP", 3) != 0) + if (strncmp(devinfo->CompatibleIdList.Ids[i].String, "PNP", 3) != 0) continue; - *pnpid++ = PNP_EISAID(devinfo->CompatibilityId.Id[i].Value); + *pnpid++ = PNP_EISAID(devinfo->CompatibleIdList.Ids[i].String); valid++; } out: - if (buf.Pointer != NULL) - AcpiOsFree(buf.Pointer); + if (devinfo) + AcpiOsFree(devinfo); return_VALUE (valid); } @@ -1419,7 +1409,7 @@ acpi_device_scan_children(device_t bus, device_t dev, int max_depth, ctx.user_fn = user_fn; ctx.arg = arg; ctx.parent = h; - return (AcpiWalkNamespace(ACPI_TYPE_ANY, h, max_depth, + return (AcpiWalkNamespace(ACPI_TYPE_ANY, h, max_depth, NULL, acpi_device_scan_cb, &ctx, NULL)); } @@ -1543,8 +1533,8 @@ acpi_probe_children(device_t bus) * devices as they appear, which might be smarter.) */ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "namespace scan\n")); - AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 100, acpi_probe_child, - bus, NULL); + AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 100, NULL, + acpi_probe_child, bus, NULL); /* Pre-allocate resources for our rman from any sysresource devices. */ acpi_sysres_alloc(bus); @@ -1700,7 +1690,7 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) * placeholder object handler so we can store a device_t in an ACPI_HANDLE. */ void -acpi_fake_objhandler(ACPI_HANDLE h, UINT32 fn, void *data) +acpi_fake_objhandler(ACPI_HANDLE h, void *data) { } @@ -1788,19 +1778,15 @@ acpi_DeviceIsPresent(device_t dev) { ACPI_DEVICE_INFO *devinfo; ACPI_HANDLE h; - ACPI_BUFFER buf; ACPI_STATUS error; int ret; ret = FALSE; if ((h = acpi_get_handle(dev)) == NULL) return (FALSE); - buf.Pointer = NULL; - buf.Length = ACPI_ALLOCATE_BUFFER; - error = AcpiGetObjectInfo(h, &buf); + error = AcpiGetObjectInfo(h, &devinfo); if (ACPI_FAILURE(error)) return (FALSE); - devinfo = (ACPI_DEVICE_INFO *)buf.Pointer; /* If no _STA method, must be present */ if ((devinfo->Valid & ACPI_VALID_STA) == 0) @@ -1810,7 +1796,7 @@ acpi_DeviceIsPresent(device_t dev) if (ACPI_DEVICE_PRESENT(devinfo->CurrentStatus)) ret = TRUE; - AcpiOsFree(buf.Pointer); + AcpiOsFree(devinfo); return (ret); } @@ -1822,19 +1808,15 @@ acpi_BatteryIsPresent(device_t dev) { ACPI_DEVICE_INFO *devinfo; ACPI_HANDLE h; - ACPI_BUFFER buf; ACPI_STATUS error; int ret; ret = FALSE; if ((h = acpi_get_handle(dev)) == NULL) return (FALSE); - buf.Pointer = NULL; - buf.Length = ACPI_ALLOCATE_BUFFER; - error = AcpiGetObjectInfo(h, &buf); + error = AcpiGetObjectInfo(h, &devinfo); if (ACPI_FAILURE(error)) return (FALSE); - devinfo = (ACPI_DEVICE_INFO *)buf.Pointer; /* If no _STA method, must be present */ if ((devinfo->Valid & ACPI_VALID_STA) == 0) @@ -1844,7 +1826,7 @@ acpi_BatteryIsPresent(device_t dev) if (ACPI_BATTERY_PRESENT(devinfo->CurrentStatus)) ret = TRUE; - AcpiOsFree(buf.Pointer); + AcpiOsFree(devinfo); return (ret); } @@ -1855,33 +1837,29 @@ BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid) { ACPI_DEVICE_INFO *devinfo; - ACPI_BUFFER buf; ACPI_STATUS error; int ret, i; ret = FALSE; if (hid == NULL || h == NULL) return (ret); - buf.Pointer = NULL; - buf.Length = ACPI_ALLOCATE_BUFFER; - error = AcpiGetObjectInfo(h, &buf); + error = AcpiGetObjectInfo(h, &devinfo); if (ACPI_FAILURE(error)) return (ret); - devinfo = (ACPI_DEVICE_INFO *)buf.Pointer; if ((devinfo->Valid & ACPI_VALID_HID) != 0 && - strcmp(hid, devinfo->HardwareId.Value) == 0) + strcmp(hid, devinfo->HardwareId.String) == 0) ret = TRUE; else if ((devinfo->Valid & ACPI_VALID_CID) != 0) { - for (i = 0; i < devinfo->CompatibilityId.Count; i++) { - if (strcmp(hid, devinfo->CompatibilityId.Id[i].Value) == 0) { + for (i = 0; i < devinfo->CompatibleIdList.Count; i++) { + if (strcmp(hid, devinfo->CompatibleIdList.Ids[i].String) == 0) { ret = TRUE; break; } } } - AcpiOsFree(buf.Pointer); + AcpiOsFree(devinfo); return (ret); } @@ -2492,7 +2470,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state) /* Initialize a device's wake GPE. */ int -acpi_wake_init(device_t dev, int type) +acpi_wake_init(device_t dev) { struct acpi_prw_data prw; @@ -2500,9 +2478,9 @@ acpi_wake_init(device_t dev, int type) if (acpi_parse_prw(acpi_get_handle(dev), &prw) != 0) return (ENXIO); - /* Set the requested type for the GPE (runtime, wake, or both). */ - if (ACPI_FAILURE(AcpiSetGpeType(prw.gpe_handle, prw.gpe_bit, type))) { - device_printf(dev, "set GPE type failed\n"); + /* Set ACPI_GPE_CAN_WAKE on the GPE */ + if (ACPI_FAILURE(AcpiSetupGpeForWake(prw.gpe_handle, NULL, prw.gpe_bit))) { + device_printf(dev, "enable GPE failed\n"); return (ENXIO); } @@ -2523,14 +2501,14 @@ acpi_wake_set_enable(device_t dev, int enable) flags = acpi_get_flags(dev); if (enable) { - status = AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); + status = AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit); if (ACPI_FAILURE(status)) { device_printf(dev, "enable wake failed\n"); return (ENXIO); } acpi_set_flags(dev, flags | ACPI_FLAG_WAKE_ENABLED); } else { - status = AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); + status = AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit); if (ACPI_FAILURE(status)) { device_printf(dev, "disable wake failed\n"); return (ENXIO); @@ -2560,7 +2538,7 @@ acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate) * and set _PSW. */ if (sstate > prw.lowest_wake) { - AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); + AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit); if (bootverbose) device_printf(dev, "wake_prep disabled wake for %s (S%d)\n", acpi_name(handle), sstate); @@ -2597,7 +2575,7 @@ acpi_wake_run_prep(ACPI_HANDLE handle, int sstate) * clear _PSW and turn off any power resources it used. */ if (sstate > prw.lowest_wake) { - AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); + AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit); if (bootverbose) device_printf(dev, "run_prep re-enabled %s\n", acpi_name(handle)); } else { @@ -2632,7 +2610,7 @@ acpi_wake_prep_walk(int sstate) ACPI_HANDLE sb_handle; if (ACPI_SUCCESS(AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &sb_handle))) - AcpiWalkNamespace(ACPI_TYPE_DEVICE, sb_handle, 100, + AcpiWalkNamespace(ACPI_TYPE_DEVICE, sb_handle, 100, NULL, acpi_wake_prep, &sstate, NULL); return (0); } diff --git a/sys/dev/acpica5/acpi_button.c b/sys/dev/acpica5/acpi_button.c index c3e454e9af..44f582ac5c 100644 --- a/sys/dev/acpica5/acpi_button.c +++ b/sys/dev/acpica5/acpi_button.c @@ -163,7 +163,7 @@ acpi_button_attach(device_t dev) } /* Enable the GPE for wake/runtime. */ - acpi_wake_init(dev, ACPI_GPE_TYPE_WAKE_RUN); + acpi_wake_init(dev); acpi_wake_set_enable(dev, 1); return_VALUE (0); diff --git a/sys/dev/acpica5/acpi_cpu_cstate.c b/sys/dev/acpica5/acpi_cpu_cstate.c index 10f772c00b..2cceeeed70 100644 --- a/sys/dev/acpica5/acpi_cpu_cstate.c +++ b/sys/dev/acpica5/acpi_cpu_cstate.c @@ -807,7 +807,7 @@ acpi_cpu_idle(void) { struct acpi_cpu_softc *sc; struct acpi_cx *cx_next; - uint32_t start_time, end_time; + uint64_t start_time, end_time; int bm_active, cx_next_idx, i; /* If disabled, return immediately. */ diff --git a/sys/dev/acpica5/acpi_ec.c b/sys/dev/acpica5/acpi_ec.c index 39ebadeb8f..432cb5a484 100644 --- a/sys/dev/acpica5/acpi_ec.c +++ b/sys/dev/acpica5/acpi_ec.c @@ -217,7 +217,8 @@ EcUnlock(struct acpi_ec_softc *sc) ACPI_SERIAL_END(ec); } -static uint32_t EcGpeHandler(void *Context); +static uint32_t EcGpeHandler(ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, void *Context); static ACPI_STATUS EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context, void **return_Context); static ACPI_STATUS EcSpaceHandler(UINT32 Function, @@ -516,15 +517,9 @@ acpi_ec_attach(device_t dev) goto error; } - /* Enable runtime GPEs for the handler. */ - Status = AcpiSetGpeType(sc->ec_gpehandle, sc->ec_gpebit, - ACPI_GPE_TYPE_RUNTIME); - if (ACPI_FAILURE(Status)) { - device_printf(dev, "AcpiSetGpeType failed: %s\n", - AcpiFormatException(Status)); - goto error; - } - Status = AcpiEnableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_NOT_ISR); + /* Enable runtime GPEs done internally by AcpiEnableGpe() */ + + Status = AcpiEnableGpe(sc->ec_gpehandle, sc->ec_gpebit); if (ACPI_FAILURE(Status)) { device_printf(dev, "AcpiEnableGpe failed: %s\n", AcpiFormatException(Status)); @@ -574,7 +569,7 @@ acpi_ec_shutdown(device_t dev) /* Disable the GPE so we don't get EC events during shutdown. */ sc = device_get_softc(dev); - AcpiDisableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_NOT_ISR); + AcpiDisableGpe(sc->ec_gpehandle, sc->ec_gpebit); return (0); } @@ -670,7 +665,7 @@ EcGpeQueryHandler(void *Context) * called from an unknown lock context. */ static uint32_t -EcGpeHandler(void *Context) +EcGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, void *Context) { struct acpi_ec_softc *sc = Context; ACPI_STATUS Status; diff --git a/sys/dev/acpica5/acpi_lid.c b/sys/dev/acpica5/acpi_lid.c index 89ca8cd6e4..3ad94f1002 100644 --- a/sys/dev/acpica5/acpi_lid.c +++ b/sys/dev/acpica5/acpi_lid.c @@ -118,7 +118,7 @@ acpi_lid_attach(device_t dev) acpi_lid_notify_handler, sc); /* Enable the GPE for wake/runtime. */ - acpi_wake_init(dev, ACPI_GPE_TYPE_WAKE_RUN); + acpi_wake_init(dev); acpi_wake_set_enable(dev, 1); return (0); diff --git a/sys/dev/acpica5/acpi_pci.c b/sys/dev/acpica5/acpi_pci.c index 16b274afc1..3936d0d57e 100644 --- a/sys/dev/acpica5/acpi_pci.c +++ b/sys/dev/acpica5/acpi_pci.c @@ -344,7 +344,7 @@ acpi_pci_attach(device_t dev) */ pci_add_children(dev, domain, busno, sizeof(struct acpi_pci_devinfo)); AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, - acpi_pci_save_handle, dev, NULL); + NULL, acpi_pci_save_handle, dev, NULL); return (bus_generic_attach(dev)); } diff --git a/sys/dev/acpica5/acpi_video/acpi_video.c b/sys/dev/acpica5/acpi_video/acpi_video.c index bc99b2a29e..3e58e5ca82 100644 --- a/sys/dev/acpica5/acpi_video/acpi_video.c +++ b/sys/dev/acpica5/acpi_video/acpi_video.c @@ -807,7 +807,7 @@ vid_enum_outputs(ACPI_HANDLE handle, argset.dod_pkg = res; argset.count = 0; status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, handle, 1, - vid_enum_outputs_subr, &argset, NULL); + NULL, vid_enum_outputs_subr, &argset, NULL); if (ACPI_FAILURE(status)) kprintf("failed walking down %s - %s\n", acpi_name(handle), AcpiFormatException(status)); diff --git a/sys/dev/acpica5/acpivar.h b/sys/dev/acpica5/acpivar.h index a511139a45..63c614da0c 100644 --- a/sys/dev/acpica5/acpivar.h +++ b/sys/dev/acpica5/acpivar.h @@ -261,7 +261,7 @@ __ACPI_BUS_ACCESSOR(acpi, magic, ACPI, MAGIC, uintptr_t) __ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *) __ACPI_BUS_ACCESSOR(acpi, flags, ACPI, FLAGS, int) -void acpi_fake_objhandler(ACPI_HANDLE h, UINT32 fn, void *data); +void acpi_fake_objhandler(ACPI_HANDLE h, void *data); static __inline device_t acpi_get_device(ACPI_HANDLE handle) { @@ -337,7 +337,7 @@ ACPI_STATUS acpi_SetIntrModel(int model); int acpi_ReqSleepState(struct acpi_softc *sc, int state); int acpi_AckSleepState(struct apm_clone_data *clone, int error); ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state); -int acpi_wake_init(device_t dev, int type); +int acpi_wake_init(device_t dev); int acpi_wake_set_enable(device_t dev, int enable); int acpi_parse_prw(ACPI_HANDLE h, struct acpi_prw_data *prw); ACPI_STATUS acpi_Startup(void); -- 2.41.0